3 test_description='Return value of diffs'
7 test_expect_success 'setup' '
10 git commit -m first &&
13 git commit -a -m second
16 test_expect_success 'git diff-tree HEAD^ HEAD' '
17 git diff-tree --exit-code HEAD^ HEAD
20 test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
21 git diff-tree --exit-code HEAD^ HEAD -- a
24 test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
25 git diff-tree --exit-code HEAD^ HEAD -- b
28 test_expect_success 'echo HEAD | git diff-tree --stdin' '
29 echo $(git rev-parse HEAD) | git diff-tree --exit-code --stdin
32 test_expect_success 'git diff-tree HEAD HEAD' '
33 git diff-tree --exit-code HEAD HEAD
36 test_expect_success 'git diff-files' '
37 git diff-files --exit-code
40 test_expect_success 'git diff-index --cached HEAD' '
41 git diff-index --exit-code --cached HEAD
44 test_expect_success 'git diff-index --cached HEAD^' '
45 git diff-index --exit-code --cached HEAD^
48 test_expect_success 'git diff-index --cached HEAD^' '
52 git diff-index --exit-code --cached HEAD^
56 test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
57 git commit -m "text in b" && {
58 git diff-tree -p --exit-code -Stext HEAD^ HEAD -- b
62 test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
63 git diff-tree -p --exit-code -Snot-found HEAD^ HEAD -- b
66 test_expect_success 'git diff-files' '
68 git diff-files --exit-code
72 test_expect_success 'git diff-index --cached HEAD' '
73 git update-index c && {
74 git diff-index --exit-code --cached HEAD
79 test_expect_success '--check --exit-code returns 0 for no difference' '
81 git diff --check --exit-code
85 test_expect_success '--check --exit-code returns 1 for a clean difference' '
88 git diff --check --exit-code
93 test_expect_success '--check --exit-code returns 3 for a dirty difference' '
96 git diff --check --exit-code
101 test_expect_success '--check with --no-pager returns 2 for dirty difference' '
103 git --no-pager diff --check
109 test_expect_success 'check should test not just the last line' '
111 git --no-pager diff --check
116 test_expect_success 'check detects leftover conflict markers' '
118 git checkout HEAD^ &&
120 git commit -m "side" b &&
121 test_must_fail git merge master &&
123 git --no-pager diff --cached --check >test.out
126 test 3 = $(grep "conflict marker" test.out | wc -l) &&