submodule: Use cat instead of echo to avoid DOS line-endings
[git/dscho.git] / t / t4035-diff-quiet.sh
blob231412d1008e45e1d788660930cab708d3912ed4
1 #!/bin/sh
3 test_description='Return value of diffs'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 echo 1 >a &&
9 git add . &&
10 git commit -m first &&
11 echo 2 >b &&
12 git add . &&
13 git commit -a -m second &&
14 mkdir -p test-outside/repo && (
15 cd test-outside/repo &&
16 git init &&
17 echo "1 1" >a &&
18 git add . &&
19 git commit -m 1
20 ) &&
21 mkdir -p test-outside/non/git && (
22 cd test-outside/non/git &&
23 echo "1 1" >a &&
24 echo "1 1" >matching-file &&
25 echo "1 1 " >trailing-space &&
26 echo "1 1" >extra-space &&
27 echo "2" >never-match
31 test_expect_success 'git diff-tree HEAD^ HEAD' '
32 git diff-tree --quiet HEAD^ HEAD >cnt
33 test $? = 1 && test_line_count = 0 cnt
35 test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
36 git diff-tree --quiet HEAD^ HEAD -- a >cnt
37 test $? = 0 && test_line_count = 0 cnt
39 test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
40 git diff-tree --quiet HEAD^ HEAD -- b >cnt
41 test $? = 1 && test_line_count = 0 cnt
43 # this diff outputs one line: sha1 of the given head
44 test_expect_success 'echo HEAD | git diff-tree --stdin' '
45 echo $(git rev-parse HEAD) | git diff-tree --quiet --stdin >cnt
46 test $? = 1 && test_line_count = 1 cnt
48 test_expect_success 'git diff-tree HEAD HEAD' '
49 git diff-tree --quiet HEAD HEAD >cnt
50 test $? = 0 && test_line_count = 0 cnt
52 test_expect_success 'git diff-files' '
53 git diff-files --quiet >cnt
54 test $? = 0 && test_line_count = 0 cnt
56 test_expect_success 'git diff-index --cached HEAD' '
57 git diff-index --quiet --cached HEAD >cnt
58 test $? = 0 && test_line_count = 0 cnt
60 test_expect_success 'git diff-index --cached HEAD^' '
61 git diff-index --quiet --cached HEAD^ >cnt
62 test $? = 1 && test_line_count = 0 cnt
64 test_expect_success 'git diff-index --cached HEAD^' '
65 echo text >>b &&
66 echo 3 >c &&
67 git add . && {
68 git diff-index --quiet --cached HEAD^ >cnt
69 test $? = 1 && test_line_count = 0 cnt
72 test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
73 git commit -m "text in b" && {
74 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt
75 test $? = 1 && test_line_count = 0 cnt
78 test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
79 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt
80 test $? = 0 && test_line_count = 0 cnt
82 test_expect_success 'git diff-files' '
83 echo 3 >>c && {
84 git diff-files --quiet >cnt
85 test $? = 1 && test_line_count = 0 cnt
88 test_expect_success 'git diff-index --cached HEAD' '
89 git update-index c && {
90 git diff-index --quiet --cached HEAD >cnt
91 test $? = 1 && test_line_count = 0 cnt
95 test_expect_success 'git diff, one file outside repo' '
97 cd test-outside/repo &&
98 test_expect_code 0 git diff --quiet a ../non/git/matching-file &&
99 test_expect_code 1 git diff --quiet a ../non/git/extra-space
103 test_expect_success 'git diff, both files outside repo' '
105 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
106 export GIT_CEILING_DIRECTORIES &&
107 cd test-outside/non/git &&
108 test_expect_code 0 git diff --quiet a matching-file &&
109 test_expect_code 1 git diff --quiet a extra-space
113 test_expect_success 'git diff --ignore-space-at-eol, one file outside repo' '
115 cd test-outside/repo &&
116 test_expect_code 0 git diff --quiet --ignore-space-at-eol a ../non/git/trailing-space &&
117 test_expect_code 1 git diff --quiet --ignore-space-at-eol a ../non/git/extra-space
121 test_expect_success 'git diff --ignore-space-at-eol, both files outside repo' '
123 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
124 export GIT_CEILING_DIRECTORIES &&
125 cd test-outside/non/git &&
126 test_expect_code 0 git diff --quiet --ignore-space-at-eol a trailing-space &&
127 test_expect_code 1 git diff --quiet --ignore-space-at-eol a extra-space
131 test_expect_success 'git diff --ignore-all-space, one file outside repo' '
133 cd test-outside/repo &&
134 test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/trailing-space &&
135 test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/extra-space &&
136 test_expect_code 1 git diff --quiet --ignore-all-space a ../non/git/never-match
140 test_expect_success 'git diff --ignore-all-space, both files outside repo' '
142 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
143 export GIT_CEILING_DIRECTORIES &&
144 cd test-outside/non/git &&
145 test_expect_code 0 git diff --quiet --ignore-all-space a trailing-space &&
146 test_expect_code 0 git diff --quiet --ignore-all-space a extra-space &&
147 test_expect_code 1 git diff --quiet --ignore-all-space a never-match
151 test_done