reftable/reader: introduce refcounting
[git/gitster.git] / t / t4035-diff-quiet.sh
blob76f8034c60fabe2cbd1ea45610e1ce3137755b0d
1 #!/bin/sh
3 test_description='Return value of diffs'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup' '
9 echo 1 >a &&
10 git add . &&
11 git commit -m first &&
12 echo 2 >b &&
13 git add . &&
14 git commit -a -m second &&
15 mkdir -p test-outside/repo && (
16 cd test-outside/repo &&
17 git init &&
18 echo "1 1" >a &&
19 git add . &&
20 git commit -m 1
21 ) &&
22 mkdir -p test-outside/non/git && (
23 cd test-outside/non/git &&
24 echo "1 1" >a &&
25 echo "1 1" >matching-file &&
26 echo "1 1 " >trailing-space &&
27 echo "1 1" >extra-space &&
28 echo "2" >never-match
32 test_expect_success 'git diff-tree HEAD^ HEAD' '
33 test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt &&
34 test_line_count = 0 cnt
36 test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
37 test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt &&
38 test_line_count = 0 cnt
40 test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
41 test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt &&
42 test_line_count = 0 cnt
44 # this diff outputs one line: sha1 of the given head
45 test_expect_success 'echo HEAD | git diff-tree --stdin' '
46 echo $(git rev-parse HEAD) |
47 test_expect_code 1 git diff-tree --quiet --stdin >cnt &&
48 test_line_count = 1 cnt
50 test_expect_success 'git diff-tree HEAD HEAD' '
51 test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
52 test_line_count = 0 cnt
54 test_expect_success 'git diff-files' '
55 test_expect_code 0 git diff-files --quiet >cnt &&
56 test_line_count = 0 cnt
58 test_expect_success 'git diff-index --cached HEAD' '
59 test_expect_code 0 git diff-index --quiet --cached HEAD >cnt &&
60 test_line_count = 0 cnt
62 test_expect_success 'git diff-index --cached HEAD^' '
63 test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
64 test_line_count = 0 cnt
66 test_expect_success 'git diff-index --cached HEAD^' '
67 echo text >>b &&
68 echo 3 >c &&
69 git add . &&
70 test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
71 test_line_count = 0 cnt
73 test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
74 git commit -m "text in b" &&
75 test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt &&
76 test_line_count = 0 cnt
78 test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
79 test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt &&
80 test_line_count = 0 cnt
82 test_expect_success 'git diff-files' '
83 echo 3 >>c &&
84 test_expect_code 1 git diff-files --quiet >cnt &&
85 test_line_count = 0 cnt
88 test_expect_success 'git diff-index --cached HEAD' '
89 git update-index c &&
90 test_expect_code 1 git diff-index --quiet --cached HEAD >cnt &&
91 test_line_count = 0 cnt
94 test_expect_success 'git diff, one file outside repo' '
96 cd test-outside/repo &&
97 test_expect_code 0 git diff --quiet a ../non/git/matching-file &&
98 test_expect_code 1 git diff --quiet a ../non/git/extra-space
102 test_expect_success 'git diff, both files outside repo' '
104 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
105 export GIT_CEILING_DIRECTORIES &&
106 cd test-outside/non/git &&
107 test_expect_code 0 git diff --quiet a matching-file &&
108 test_expect_code 1 git diff --quiet a extra-space
112 test_expect_success 'git diff --ignore-space-at-eol, one file outside repo' '
114 cd test-outside/repo &&
115 test_expect_code 0 git diff --quiet --ignore-space-at-eol a ../non/git/trailing-space &&
116 test_expect_code 1 git diff --quiet --ignore-space-at-eol a ../non/git/extra-space
120 test_expect_success 'git diff --ignore-space-at-eol, both files outside repo' '
122 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
123 export GIT_CEILING_DIRECTORIES &&
124 cd test-outside/non/git &&
125 test_expect_code 0 git diff --quiet --ignore-space-at-eol a trailing-space &&
126 test_expect_code 1 git diff --quiet --ignore-space-at-eol a extra-space
130 test_expect_success 'git diff --ignore-all-space, one file outside repo' '
132 cd test-outside/repo &&
133 test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/trailing-space &&
134 test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/extra-space &&
135 test_expect_code 1 git diff --quiet --ignore-all-space a ../non/git/never-match
139 test_expect_success 'git diff --ignore-all-space, both files outside repo' '
141 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
142 export GIT_CEILING_DIRECTORIES &&
143 cd test-outside/non/git &&
144 test_expect_code 0 git diff --quiet --ignore-all-space a trailing-space &&
145 test_expect_code 0 git diff --quiet --ignore-all-space a extra-space &&
146 test_expect_code 1 git diff --quiet --ignore-all-space a never-match
150 test_expect_success 'git diff --quiet ignores stat-change only entries' '
151 test-tool chmtime +10 a &&
152 echo modified >>b &&
153 test_expect_code 1 git diff --quiet
156 test_expect_success 'git diff --quiet on a path that need conversion' '
157 echo "crlf.txt text=auto" >.gitattributes &&
158 printf "Hello\r\nWorld\r\n" >crlf.txt &&
159 git add .gitattributes crlf.txt &&
161 printf "Hello\r\nWorld\n" >crlf.txt &&
162 git diff --quiet crlf.txt
165 test_done