3 test_description
='Return value of diffs'
7 test_expect_success
'setup' '
10 git commit -m zeroth &&
13 git commit -m first &&
16 git commit -a -m second
19 test_expect_success
'git diff --quiet -w HEAD^^ HEAD^' '
20 git diff --quiet -w HEAD^^ HEAD^
23 test_expect_success
'git diff --quiet HEAD^^ HEAD^' '
24 test_must_fail git diff --quiet HEAD^^ HEAD^
27 test_expect_success
'git diff --quiet -w HEAD^ HEAD' '
28 test_must_fail git diff --quiet -w HEAD^ HEAD
31 test_expect_success
'git diff-tree HEAD^ HEAD' '
32 git diff-tree --exit-code HEAD^ HEAD
35 test_expect_success
'git diff-tree HEAD^ HEAD -- a' '
36 git diff-tree --exit-code HEAD^ HEAD -- a
39 test_expect_success
'git diff-tree HEAD^ HEAD -- b' '
40 git diff-tree --exit-code HEAD^ HEAD -- b
43 test_expect_success
'echo HEAD | git diff-tree --stdin' '
44 echo $(git rev-parse HEAD) | git diff-tree --exit-code --stdin
47 test_expect_success
'git diff-tree HEAD HEAD' '
48 git diff-tree --exit-code HEAD HEAD
51 test_expect_success
'git diff-files' '
52 git diff-files --exit-code
55 test_expect_success
'git diff-index --cached HEAD' '
56 git diff-index --exit-code --cached HEAD
59 test_expect_success
'git diff-index --cached HEAD^' '
60 git diff-index --exit-code --cached HEAD^
63 test_expect_success
'git diff-index --cached HEAD^' '
67 git diff-index --exit-code --cached HEAD^
71 test_expect_success
'git diff-tree -Stext HEAD^ HEAD -- b' '
72 git commit -m "text in b" && {
73 git diff-tree -p --exit-code -Stext HEAD^ HEAD -- b
77 test_expect_success
'git diff-tree -Snot-found HEAD^ HEAD -- b' '
78 git diff-tree -p --exit-code -Snot-found HEAD^ HEAD -- b
81 test_expect_success
'git diff-files' '
83 git diff-files --exit-code
87 test_expect_success
'git diff-index --cached HEAD' '
88 git update-index c && {
89 git diff-index --exit-code --cached HEAD
94 test_expect_success
'--check --exit-code returns 0 for no difference' '
96 git diff --check --exit-code
100 test_expect_success
'--check --exit-code returns 1 for a clean difference' '
103 git diff --check --exit-code
108 test_expect_success
'--check --exit-code returns 3 for a dirty difference' '
111 git diff --check --exit-code
116 test_expect_success
'--check with --no-pager returns 2 for dirty difference' '
118 git --no-pager diff --check
124 test_expect_success
'check should test not just the last line' '
126 git --no-pager diff --check
131 test_expect_success
'check detects leftover conflict markers' '
133 git checkout HEAD^ &&
135 git commit -m "side" b &&
136 test_must_fail git merge master &&
138 git --no-pager diff --cached --check >test.out
141 test 3 = $(grep "conflict marker" test.out | wc -l) &&