summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b4ce54f)
raw | patch | inline | side by side (parent: b4ce54f)
author | Jeff King <peff@peff.net> | |
Wed, 12 Mar 2008 21:36:36 +0000 (17:36 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 13 Mar 2008 07:57:52 +0000 (00:57 -0700) |
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>
"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>
40 files changed:
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 47f08a46c260a612eff2bcf88bef84ee231897c1..3faf135e38ccbe71241679da464d7cf709ae73d7 100755 (executable)
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
git check-attr test -- "$path" >actual &&
echo "$path: test: $2" >expect &&
- diff -u expect actual
+ test_cmp expect actual
}
diff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh
index 430a1d1d385b756c921652b2fc3580a727c57917..7d1ce2d0563b3734d754c171d21580075264bbb2 100755 (executable)
--- a/t/t0022-crlf-rename.sh
+++ b/t/t0022-crlf-rename.sh
git diff-tree -M -r --name-status HEAD^ HEAD |
sed -e "s/R[0-9]*/RNUM/" >actual &&
echo "RNUM sample elpmas" >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
index 8c4556408ecc81985acd7b8237921330c326e787..b0d31f5a9bb8b3474665147327d94ad5067fa206 100755 (executable)
test_expect_success 'reset should work' '
git read-tree -u --reset HEAD^ &&
git ls-files >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
test_done
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 24f892f79386478fd5f1162654cb9b72d940bbe4..b664341926071a3286ba949dc09b5e62b280e79a 100755 (executable)
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
sed -e "s/ 0 / /" >expect &&
git ls-tree -r $(git write-tree) |
sed -e "s/ blob / /" >current &&
- diff -u expect current
+ test_cmp expect current
'
index b4297bacf2bd3d6da0f7fd01fba65741cf568003..55f057cebeb37a8ba8cd9c1e6aa5101c66988bcb 100755 (executable)
EOF
test_expect_success 'git-status honours core.excludesfile' \
- 'diff -u expect output'
+ 'test_cmp expect output'
test_expect_success 'trailing slash in exclude allows directory match(1)' '
index 34f26a8d9ed809f07d1ae5eec847c2f0ac1d2b5e..2b21b1070d6b8f864aee0049d5cb2dccef0daa46 100755 (executable)
cd cloned &&
(git rev-parse HEAD; git ls-files -s) >../actual
) &&
- diff -u expected actual
+ test_cmp expected actual
'
test_expect_success advance '
git pull &&
(git rev-parse HEAD; git ls-files -s) >../actual
) &&
- diff -u expected actual
+ test_cmp expected actual
'
test_done
index 68eb266d73532b308754ef350ec2ff05a50b3c50..3ce501bb9794900b99fbbf2f2ccfbb330f7947a7 100755 (executable)
cd ..
test_expect_success \
'git -ls-files --with-tree should add entries from named tree.' \
- 'diff -u expected output'
+ 'test_cmp expected output'
test_done
index 9ef593f0e11d85a62c5bbfe89febf0fce2c20fd7..b4cf628d225d380d6c0bf73dee4c3e9df0cadb41 100755 (executable)
{
echo " master" && echo "* side"
} >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
{
echo " master" && echo "* side"
} >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
{
echo "* side"
} >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
index 9c0acc5a7e59bb1279d0f512ceed4b698d39474d..9cf873f7ebfa8f8a4fd215cbbb468f955d6a47e3 100755 (executable)
test_expect_success 'stop on conflicting pick' '
git tag new-branch1 &&
! git rebase -i master &&
- diff -u expect .git/.dotest-merge/patch &&
- diff -u expect2 file1 &&
+ test_cmp expect .git/.dotest-merge/patch &&
+ test_cmp expect2 file1 &&
test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) &&
test 0 = $(grep -c "^[^#]" < .git/.dotest-merge/git-rebase-todo)
'
index e4e2e649ed03394f623eb0d135815c3d570a3186..e5ad67c643ffee9b79fce813673732faa950714f 100755 (executable)
git rebase master side &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
- diff -u F0 F1 &&
- diff -u F F0
+ test_cmp F0 F1 &&
+ test_cmp F F0
'
test_done
index 332b2b2feb6441e4fe34fe234c3c873ffbd0c81a..539108094345e3e0ba4cf03fc20a5ca6486fa230 100755 (executable)
git rebase -m master >report &&
sed -n -e "/^Already applied: /p" \
-e "/^Committed: /p" report >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
index c8dc1ac24111f2d77d79d4e7bfdad360e5307481..77c90f6fa002ce00c3ffb30d0b79adaff46b3caa 100755 (executable)
test_expect_success 'diff works (initial)' '
(echo d; echo 1) | git add -i >output &&
sed -ne "/new file/,/content/p" <output >diff &&
- diff -u expected diff
+ test_cmp expected diff
'
test_expect_success 'revert works (initial)' '
git add file &&
test_expect_success 'diff works (commit)' '
(echo d; echo 1) | git add -i >output &&
sed -ne "/^index/,/content/p" <output >diff &&
- diff -u expected diff
+ test_cmp expected diff
'
test_expect_success 'revert works (commit)' '
git add file &&
diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh
index 73da45f18c2c5a58828c56c561e27012aa901a9a..fe4fb5116ac4c482c357f0af3f0a34da27cee237 100755 (executable)
--- a/t/t3902-quoted.sh
+++ b/t/t3902-quoted.sh
test_expect_success 'check fully quoted output from ls-files' '
- git ls-files >current && diff -u expect.quoted current
+ git ls-files >current && test_cmp expect.quoted current
'
test_expect_success 'check fully quoted output from diff-files' '
git diff --name-only >current &&
- diff -u expect.quoted current
+ test_cmp expect.quoted current
'
test_expect_success 'check fully quoted output from diff-index' '
git diff --name-only HEAD >current &&
- diff -u expect.quoted current
+ test_cmp expect.quoted current
'
test_expect_success 'check fully quoted output from diff-tree' '
git diff --name-only HEAD^ HEAD >current &&
- diff -u expect.quoted current
+ test_cmp expect.quoted current
'
test_expect_success 'check fully quoted output from ls-files' '
- git ls-files >current && diff -u expect.raw current
+ git ls-files >current && test_cmp expect.raw current
'
test_expect_success 'check fully quoted output from diff-files' '
git diff --name-only >current &&
- diff -u expect.raw current
+ test_cmp expect.raw current
'
test_expect_success 'check fully quoted output from diff-index' '
git diff --name-only HEAD >current &&
- diff -u expect.raw current
+ test_cmp expect.raw current
'
test_expect_success 'check fully quoted output from diff-tree' '
git diff --name-only HEAD^ HEAD >current &&
- diff -u expect.raw current
+ test_cmp expect.raw current
'
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index aa282e1bc1e17f08dd12fc1980187c786f1de99b..2d3ee3b78c66e4e964fffccaa1ae8252929c1732 100755 (executable)
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
test_expect_success 'parents of stash' '
test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
git diff stash^2..stash > output &&
- diff -u output expect
+ test_cmp output expect
'
test_expect_success 'apply needs clean working directory' '
index 255604effd5ad6d0549e818d489fa91b3af8f2d7..4dbfc6e8b751a6c93b1f9dfee8ce649235c98c93 100755 (executable)
echo "R100 foo bar"
echo "R100 bar foo"
} | sort >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
echo "R100 foo bar"
echo "R100 bar foo"
} | sort >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
echo "R100 foo bar"
echo "T100 foo"
} | sort >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
index 3c66102f7ade654bb2ee0e0d732f86a301d1cb1e..c4d733f5db6a4d390762505b770954cdbf6cc82f 100755 (executable)
do
git diff -U0 file-?$n
done | zc >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
diff --git a/t/t4025-hunk-header.sh b/t/t4025-hunk-header.sh
index 9ba06b74ce1a68c49ca76be66743a0c8ebd56cb3..7a3dbc1ea22fd19a54da8949abc368c112377b19 100755 (executable)
--- a/t/t4025-hunk-header.sh
+++ b/t/t4025-hunk-header.sh
echo " A $N$N$N$N$N$N$N$N$N2"
echo " L $N$N$N$N$N$N$N$N$N1"
) >expected &&
- diff -u actual expected
+ test_cmp actual expected
'
index 3d2d0816a3656a0df347fbd29571f5c38513c27f..1fd3fb74d763026d4e20a38fe9d2ed48dda74fed 100755 (executable)
test_expect_success 'git diff --raw HEAD' '
git diff --raw --abbrev=40 HEAD >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
test_expect_success 'git diff-index --raw HEAD' '
git diff-index --raw HEAD >actual.index &&
- diff -u expect actual.index
+ test_cmp expect actual.index
'
test_expect_success 'git diff-files --raw' '
git diff-files --raw >actual.files &&
- diff -u expect actual.files
+ test_cmp expect actual.files
'
test_done
diff --git a/t/t4105-apply-fuzz.sh b/t/t4105-apply-fuzz.sh
index 0e8d25f18b0ccf027735017227d9eed10d01bc8b..3266e394003958b62509b7bfe6652abd03fdfcb7 100755 (executable)
--- a/t/t4105-apply-fuzz.sh
+++ b/t/t4105-apply-fuzz.sh
test_expect_success "$name" "
git checkout-index -f -q -u file &&
git apply $* &&
- diff -u expect file
+ test_cmp expect file
"
}
index d6f15be6718d581bb2a8e3ef05930977b8dffdb9..3b471b641ba2d3274dd1ab89948485ff8ce4dfdb 100755 (executable)
--- a/t/t4125-apply-ws-fuzz.sh
+++ b/t/t4125-apply-ws-fuzz.sh
git apply --whitespace=nowarn patch-1 &&
# The result should obviously match.
- diff -u file-1 file
+ test_cmp file-1 file
'
test_expect_success 'withfix (forward)' '
git apply --whitespace=fix patch-0 &&
git apply --whitespace=fix patch-1 &&
- diff -u file-fixed file
+ test_cmp file-fixed file
'
test_expect_success 'withfix (backward)' '
sed -e /h/d file-fixed >fixed-head &&
sed -e /h/d file >file-head &&
- diff -u fixed-head file-head &&
+ test_cmp fixed-head file-head &&
sed -n -e /h/p file-fixed >fixed-tail &&
sed -n -e /h/p file >file-tail &&
- ! diff -u fixed-tail file-tail
+ ! test_cmp fixed-tail file-tail
'
diff --git a/t/t4150-am-subdir.sh b/t/t4150-am-subdir.sh
index 929d2cbd878cf927e56af35a982f34d756bbce60..52069b469bdeefed921fbc574d12e9d2490f0e8c 100755 (executable)
--- a/t/t4150-am-subdir.sh
+++ b/t/t4150-am-subdir.sh
git checkout initial &&
git am <patchfile &&
git diff master >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
test_expect_success 'am regularly from file' '
git checkout initial &&
git am patchfile &&
git diff master >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
test_expect_success 'am regularly from stdin in subdirectory' '
git am <../patchfile
) &&
git diff master>actual &&
- diff -u expect actual
+ test_cmp expect actual
'
test_expect_success 'am regularly from file in subdirectory' '
git am ../patchfile
) &&
git diff master >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
test_expect_success 'am regularly from file in subdirectory with full path' '
git am "$P/patchfile"
) &&
git diff master >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
test_done
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 6d12efb74d8bedede8e476429b2fccd648eb05a3..91ea69631472d9a13184a58a41a55277746b1498 100755 (executable)
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
EOF
-test_expect_success 'shortlog wrapping' 'diff -u expect out'
+test_expect_success 'shortlog wrapping' 'test_cmp expect out'
test_done
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2822a651b5c434bb9243a6f8f9069a8fee1ad590..ecfc999aaae728e3f57beaab60490abc53a3fb23 100755 (executable)
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
tokens_match () {
echo "$1" | tr ' ' '\012' | sort | sed -e '/^$/d' >expect &&
echo "$2" | tr ' ' '\012' | sort | sed -e '/^$/d' >actual &&
- diff -u expect actual
+ test_cmp expect actual
}
check_remote_track () {
sed -e "/^refs\/remotes\/origin\//d" \
-e "/^refs\/remotes\/second\//d" >actual &&
>expect &&
- diff -u expect actual
+ test_cmp expect actual
)
'
git for-each-ref "--format=%(refname)" refs/remotes |
sed -e "/^refs\/remotes\/origin\//d" >actual &&
>expect &&
- diff -u expect actual
+ test_cmp expect actual
)
'
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 9b948c14e6f92e8154373154b32a6d450ead47af..6946557c677ccc190309cd5961b046c420174f7d 100755 (executable)
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
do
echo "$(git rev-parse --verify $h) $h"
done >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 6ec5f7c48bdde7ff41e14c1e355b79387140ecf0..c0dc94909b694439e389ceeeecec82ed36864ec0 100755 (executable)
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
test_expect_success 'ls-remote --tags .git' '
git ls-remote --tags .git >actual &&
- diff -u expected.tag actual
+ test_cmp expected.tag actual
'
test_expect_success 'ls-remote .git' '
git ls-remote .git >actual &&
- diff -u expected.all actual
+ test_cmp expected.all actual
'
test_expect_success 'ls-remote --tags self' '
git ls-remote --tags self >actual &&
- diff -u expected.tag actual
+ test_cmp expected.tag actual
'
test_expect_success 'ls-remote self' '
git ls-remote self >actual &&
- diff -u expected.all actual
+ test_cmp expected.all actual
'
index 80d71988b8464b6abe2b13e3052b54a4bb84604f..5dabf1c5e354c28cc593bd0ea8e4b0d5f0d56d67 100755 (executable)
test_expect_success 'path optimization 2' '
( echo "$side"; echo "$initial" ) >expected &&
git rev-list HEAD -- a >actual &&
- diff -u expected actual
+ test_cmp expected actual
'
test_done
index be3d238d996fed911d6098fad01ca25345059da6..f248a3293c5d126c60dc525e410e99d5c48a8c04 100755 (executable)
git rev-list one --not four >result &&
>expect &&
- diff -u expect result
+ test_cmp expect result
'
index a7358f75b19ed75d58124a3f1e070f022a2367bb..92ca1f0f8ccabe6f01159ea3e4a73683387ec4a3 100755 (executable)
--- a/t/t6027-merge-binary.sh
+++ b/t/t6027-merge-binary.sh
false
else
git ls-files -s >current
- diff -u current expect
+ test_cmp current expect
fi
'
false
else
git ls-files -s >current
- diff -u current expect
+ test_cmp current expect
fi
'
index 35d66e804416af7f773d9eebcacb310f0e788884..43f5459c35dd862b2b15b9883a4f2354a20e8e25 100755 (executable)
--- a/t/t6029-merge-subtree.sh
+++ b/t/t6029-merge-subtree.sh
git merge -s subtree side &&
for i in mundo $s world; do echo $i; done >expect &&
- diff -u expect hello
+ test_cmp expect hello
'
diff --git a/t/t7010-setup.sh b/t/t7010-setup.sh
index bc8ab6a61913169325de3b04fee17d04033b54e1..02cf7c5c9dc5ba9ea66d9dc109a11d300c7bd817 100755 (executable)
--- a/t/t7010-setup.sh
+++ b/t/t7010-setup.sh
git add "$D/a/b/c/d" &&
git ls-files >current &&
echo a/b/c/d >expect &&
- diff -u expect current
+ test_cmp expect current
'
) &&
git ls-files >current &&
echo a/e/f >expect &&
- diff -u expect current
+ test_cmp expect current
'
git rm -f --cached "$D/a/b/c/d" &&
git ls-files >current &&
echo a/e/f >expect &&
- diff -u expect current
+ test_cmp expect current
'
) &&
git ls-files >current &&
echo a/b/c/d >expect &&
- diff -u expect current
+ test_cmp expect current
'
git add a &&
git ls-files "$D/a/e/../b" >current &&
echo a/b/c/d >expect &&
- diff -u expect current
+ test_cmp expect current
'
git ls-files "../b/c"
) >current &&
echo c/d >expect &&
- diff -u expect current
+ test_cmp expect current
'
git ls-files --full-name "../e/f"
) >current &&
echo a/e/f >expect &&
- diff -u expect current
+ test_cmp expect current
'
git log a/b/c/d >f1.txt &&
git log "$(pwd)/a/b/c/d" >f2.txt &&
- diff -u f1.txt f2.txt
+ test_cmp f1.txt f2.txt
'
test_expect_success 'blame using absolute path names' '
git blame a/b/c/d >f1.txt &&
git blame "$(pwd)/a/b/c/d" >f2.txt &&
- diff -u f1.txt f2.txt
+ test_cmp f1.txt f2.txt
'
test_expect_success 'setup deeper work tree' '
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 63915cd87b74aaddb943f45057bda10d283b4351..3111baa9e38ecf96de6385dc9241ea8c992e4992 100755 (executable)
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
fill 0 1 2 3 4 5 6 7 8 >same &&
cp same kept
git checkout side >messages &&
- diff -u same kept
+ test_cmp same kept
(cat > messages.expect <<EOF
M same
EOF
) &&
touch messages.expect &&
- diff -u messages.expect messages
+ test_cmp messages.expect messages
'
test_expect_success "checkout -m with dirty tree" '
M one
EOF
) &&
- diff -u expect.messages messages &&
+ test_cmp expect.messages messages &&
fill "M one" "A three" "D two" >expect.master &&
git diff --name-status master >current.master &&
- diff -u expect.master current.master &&
+ test_cmp expect.master current.master &&
fill "M one" >expect.side &&
git diff --name-status side >current.side &&
- diff -u expect.side current.side &&
+ test_cmp expect.side current.side &&
: >expect.index &&
git diff --cached >current.index &&
- diff -u expect.index current.index
+ test_cmp expect.index current.index
'
test_expect_success "checkout -m with dirty tree, renamed" '
git checkout -m renamer &&
fill 1 3 4 5 7 8 >expect &&
- diff -u expect uno &&
+ test_cmp expect uno &&
! test -f one &&
git diff --cached >current &&
! test -s current
git diff master:one :3:uno |
sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
fill d2 aT d7 aS >expect &&
- diff -u current expect &&
+ test_cmp current expect &&
git diff --cached two >current &&
! test -s current
'
HEAD is now at 7329388... Initial A one, A two
EOF
) &&
- diff -u messages.expect messages &&
+ test_cmp messages.expect messages &&
H=$(git rev-parse --verify HEAD) &&
M=$(git show-ref -s --verify refs/heads/master) &&
test "z$H" = "z$M" &&
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 361886c3d62b8bf81db0be5999c1e98c4e972f6a..c0288f345fb5809d8606f4d3cfaf73d24d6c7281 100755 (executable)
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
) >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
) >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
echo
echo three
) >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
git merge -s ours side -m "empty ok" &&
git diff HEAD^ HEAD >actual &&
: >expected &&
- diff -u expected actual &&
+ test_cmp expected actual &&
git commit --amend -m "empty really ok" &&
git diff HEAD^ HEAD >actual &&
: >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
git commit --allow-empty --amend -C "$old" &&
git show --pretty="format:%ad %s" "$old" >expected &&
git show --pretty="format:%ad %s" HEAD >actual &&
- diff -u expected actual
+ test_cmp expected actual
'
git commit --allow-empty --amend -C tagged-old &&
git show --pretty="format:%ad %s" "$old" >expected &&
git show --pretty="format:%ad %s" HEAD >actual &&
- diff -u expected actual
+ test_cmp expected actual
'
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index b780fddc08f9c01eaf1143b9178ab5b7ecd032db..284c9412474754be649ccc51df996e3e370ac6ec 100755 (executable)
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
git add negative &&
git status -v | sed -ne "/^diff --git /p" >actual &&
echo "diff --git a/negative b/negative" >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
{ echo;echo "# text";echo; } >expect &&
git commit --cleanup=verbatim -t expect -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d" |head -n 3 >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
echo >>negative &&
git commit --cleanup=verbatim -F expect -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
echo >>negative &&
git commit --cleanup=verbatim -m "$(cat expect)" -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
echo "# text" >expect &&
git commit --cleanup=whitespace -F text -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
echo sample >expect &&
git commit --cleanup=strip -F text -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
{ echo;echo sample;echo; } >text &&
git commit -e -F text -a &&
head -n 4 .git/COMMIT_EDITMSG >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
diff --git a/t/t7502-status.sh b/t/t7502-status.sh
index 70b802ba3d4f9d985126158b1df615859986bc81..cd08516e6de6b5c4b39ffee14302d76c99229825 100755 (executable)
--- a/t/t7502-status.sh
+++ b/t/t7502-status.sh
EOF
test_expect_success 'status of partial commit excluding new file in index' '
git status dir1/modified >output &&
- diff -u expect output
+ test_cmp expect output
'
test_done
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 219411fd02f92a6af5f226912971ca43ae020003..56869aceeda90281a9fed992d0b202ec03fcb9f9 100755 (executable)
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
}
verify_diff() {
- if ! diff -u "$1" "$2"
+ if ! test_cmp "$1" "$2"
then
echo "$3"
false
diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh
index db51b3a6bb85c466781139fd1f203b8f9b965710..966bb0a61a89ed63dec085338d3c45f766a7f777 100755 (executable)
--- a/t/t8003-blame.sh
+++ b/t/t8003-blame.sh
echo mouse-Second
echo mouse-Third
} >expected &&
- diff -u expected current
+ test_cmp expected current
'
echo cow-Fifth
echo mouse-Third
} >expected &&
- diff -u expected current
+ test_cmp expected current
'
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index cbbfa9cb4986403cb214bba6c2216c85471469c9..c0973b4e6ee2c6a55d1573e2341607c4adfcbb10 100755 (executable)
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
>actual-show-all-headers &&
- diff -u expected-show-all-headers actual-show-all-headers
+ test_cmp expected-show-all-headers actual-show-all-headers
'
z8=zzzzzzzz
diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh
index 902ed4145de5f41f3b0522fac464594e9f6e792b..e1e8bdf0e37928c20e6bf24c08aaf574268cb037 100755 (executable)
--- a/t/t9116-git-svn-log.sh
+++ b/t/t9116-git-svn-log.sh
test_expect_success 'test ascending revision range' "
git reset --hard trunk &&
- git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r1-r2-r4 -
+ git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
"
printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
test_expect_success 'test descending revision range' "
git reset --hard trunk &&
- git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4-r2-r1 -
+ git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
"
printf 'r1 \nr2 \n' > expected-range-r1-r2
test_expect_success 'test ascending revision range with unreachable revision' "
git reset --hard trunk &&
- git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r1-r2 -
+ git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
"
printf 'r2 \nr1 \n' > expected-range-r2-r1
test_expect_success 'test descending revision range with unreachable revision' "
git reset --hard trunk &&
- git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r2-r1 -
+ git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
"
printf 'r2 \n' > expected-range-r2
test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r2 -
+ git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
"
test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r2 -
+ git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
"
printf 'r4 \n' > expected-range-r4
test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
printf -- '------------------------------------------------------------------------\n' > expected-separator
test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
git reset --hard trunk &&
- git svn log -r 5:6 | diff -u expected-separator -
+ git svn log -r 5:6 | test_cmp expected-separator -
"
test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
git reset --hard trunk &&
- git svn log -r 6:5 | diff -u expected-separator -
+ git svn log -r 6:5 | test_cmp expected-separator -
"
test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
git reset --hard trunk &&
- git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
git reset --hard trunk &&
- git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_done
index 58c59ed5ae0159810b4c8258f9182991bad33636..42b144b1b3f38b406b09ae7bff455f1e436ee33c 100755 (executable)
else
printf '%s\n' "$2" | tr '|' '\012' >expected
fi
- diff -u expected actual
+ test_cmp expected actual
}
test_expect_success \
(cd "$GIT_DIR" &&
GIT_DIR=. git cvsexportcommit -w "$CVSWORK" -c $id &&
check_entries "$CVSWORK/W" "file1.txt/1.1/|file2.txt/1.1/" &&
- diff -u "$CVSWORK/W/file1.txt" ../W/file1.txt &&
- diff -u "$CVSWORK/W/file2.txt" ../W/file2.txt
+ test_cmp "$CVSWORK/W/file1.txt" ../W/file1.txt &&
+ test_cmp "$CVSWORK/W/file2.txt" ../W/file2.txt
)
'
git cvsexportcommit -w "$CVSWORK" -c $id &&
check_entries "$CVSWORK/E" "DS/1.1/|newfile5.txt/1.1/" &&
check_entries "$CVSWORK" "DS/1.1/|release-notes/1.2/" &&
- diff -u "$CVSWORK/DS" DS &&
- diff -u "$CVSWORK/E/DS" E/DS &&
- diff -u "$CVSWORK/release-notes" release-notes
+ test_cmp "$CVSWORK/DS" DS &&
+ test_cmp "$CVSWORK/E/DS" E/DS &&
+ test_cmp "$CVSWORK/release-notes" release-notes
'
id=$(git rev-parse HEAD) &&
git cvsexportcommit -w "$CVSWORK" -c $id &&
check_entries "$CVSWORK" " space/1.1/|DS/1.1/|release-notes/1.2/" &&
- diff -u "$CVSWORK/ space" " space"
+ test_cmp "$CVSWORK/ space" " space"
'
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 6aea0ea0a579973c9baddff608ea92445ef9fcbb..268b26c959692f8f575fb088143a92c4785b1214 100644 (file)
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR VISUAL
+GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
# Protect ourselves from common misconfiguration to export
# CDPATH into the environment
test $? -gt 0 -a $? -le 128
}
+# test_cmp is a helper function to compare actual and expected output.
+# You can use it like:
+#
+# test_expect_success 'foo works' '
+# echo expected >expected &&
+# foo >actual &&
+# test_cmp expected actual
+# '
+#
+# This could be written as either "cmp" or "diff -u", but:
+# - cmp's output is not nearly as easy to read as diff -u
+# - not all diff versions understand "-u"
+
+test_cmp() {
+ $GIT_TEST_CMP "$@"
+}
+
# Most tests can use the created repository, but some may need to create more.
# Usage: test_create_repo <directory>
test_create_repo () {