Skip to content

Commit

Permalink
t6050: add tests for listing with --format
Browse files Browse the repository at this point in the history
This patch adds tests for "git replace -l --format=<fmt>".

'short', 'medium' and 'full' are the only allowed values
for <fmt>.

'short' is the same as with no --format option.
Tests for 'medium' and 'full' are the most needed.

Signed-off-by: Christian Couder <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
chriscool authored and gitster committed Dec 12, 2013
1 parent 44f9f85 commit bbbb4af
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions t/t6050-replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,43 @@ test_expect_success 'git cat-file --batch works on replace objects' '
echo $PARA3 | git cat-file --batch
'

test_expect_success 'test --format bogus' '
test_must_fail git replace --format bogus >/dev/null 2>&1
'

test_expect_success 'test --format short' '
git replace --format=short >actual &&
git replace >expected &&
test_cmp expected actual
'

test_expect_success 'test --format medium' '
H1=$(git --no-replace-objects rev-parse HEAD~1) &&
HT=$(git --no-replace-objects rev-parse HEAD^{tree}) &&
MYTAG=$(git --no-replace-objects rev-parse mytag) &&
{
echo "$H1 -> $BLOB" &&
echo "$BLOB -> $REPLACED" &&
echo "$HT -> $H1" &&
echo "$PARA3 -> $S" &&
echo "$MYTAG -> $HASH1"
} | sort >expected &&
git replace -l --format medium | sort > actual &&
test_cmp expected actual
'

test_expect_failure 'test --format full' '
{
echo "$H1 (commit) -> $BLOB (blob)" &&
echo "$BLOB (blob) -> $REPLACED (blob)" &&
echo "$HT (tree) -> $H1 (commit)" &&
echo "$PARA3 (commit) -> $S (commit)" &&
echo "$MYTAG (tag) -> $HASH1 (commit)"
} | sort >expected &&
git replace --format=full | sort > actual &&
test_cmp expected actual
'

test_expect_success 'replace ref cleanup' '
test -n "$(git replace)" &&
git replace -d $(git replace) &&
Expand Down

0 comments on commit bbbb4af

Please sign in to comment.