mirror of
https://github.com/git/git.git
synced 2024-11-14 13:13:01 +01:00
82ebb0b6ec
Many scripts compare actual and expected output using "diff -u". This is nicer than "cmp" because the output shows how the two differ. However, not all versions of diff understand -u, leading to unnecessary test failure. This adds a test_cmp function to the test scripts and switches all "diff -u" invocations to use it. The function uses the contents of "$GIT_TEST_CMP" to compare its arguments; the default is "diff -u". On systems with a less-capable diff, you can do: GIT_TEST_CMP=cmp make test Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
51 lines
1.2 KiB
Bash
Executable file
51 lines
1.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='git rev-list trivial path optimization test'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
echo Hello > a &&
|
|
git add a &&
|
|
git commit -m "Initial commit" a &&
|
|
initial=$(git rev-parse --verify HEAD)
|
|
'
|
|
|
|
test_expect_success path-optimization '
|
|
commit=$(echo "Unchanged tree" | git commit-tree "HEAD^{tree}" -p HEAD) &&
|
|
test $(git rev-list $commit | wc -l) = 2 &&
|
|
test $(git rev-list $commit -- . | wc -l) = 1
|
|
'
|
|
|
|
test_expect_success 'further setup' '
|
|
git checkout -b side &&
|
|
echo Irrelevant >c &&
|
|
git add c &&
|
|
git commit -m "Side makes an irrelevant commit" &&
|
|
echo "More Irrelevancy" >c &&
|
|
git add c &&
|
|
git commit -m "Side makes another irrelevant commit" &&
|
|
echo Bye >a &&
|
|
git add a &&
|
|
git commit -m "Side touches a" &&
|
|
side=$(git rev-parse --verify HEAD) &&
|
|
echo "Yet more Irrelevancy" >c &&
|
|
git add c &&
|
|
git commit -m "Side makes yet another irrelevant commit" &&
|
|
git checkout master &&
|
|
echo Another >b &&
|
|
git add b &&
|
|
git commit -m "Master touches b" &&
|
|
git merge side &&
|
|
echo Touched >b &&
|
|
git add b &&
|
|
git commit -m "Master touches b again"
|
|
'
|
|
|
|
test_expect_success 'path optimization 2' '
|
|
( echo "$side"; echo "$initial" ) >expected &&
|
|
git rev-list HEAD -- a >actual &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_done
|