apply: update line lengths for --inaccurate-eof
[git/raj.git] / t / t4035-diff-quiet.sh
blob2f1737fcef185486dc626d616c37fdadc11deba1
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 test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt &&
33 test_line_count = 0 cnt
35 test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
36 test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt &&
37 test_line_count = 0 cnt
39 test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
40 test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt &&
41 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) |
46 test_expect_code 1 git diff-tree --quiet --stdin >cnt &&
47 test_line_count = 1 cnt
49 test_expect_success 'git diff-tree HEAD HEAD' '
50 test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
51 test_line_count = 0 cnt
53 test_expect_success 'git diff-files' '
54 test_expect_code 0 git diff-files --quiet >cnt &&
55 test_line_count = 0 cnt
57 test_expect_success 'git diff-index --cached HEAD' '
58 test_expect_code 0 git diff-index --quiet --cached HEAD >cnt &&
59 test_line_count = 0 cnt
61 test_expect_success 'git diff-index --cached HEAD^' '
62 test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
63 test_line_count = 0 cnt
65 test_expect_success 'git diff-index --cached HEAD^' '
66 echo text >>b &&
67 echo 3 >c &&
68 git add . &&
69 test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
70 test_line_count = 0 cnt
72 test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
73 git commit -m "text in b" &&
74 test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt &&
75 test_line_count = 0 cnt
77 test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
78 test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt &&
79 test_line_count = 0 cnt
81 test_expect_success 'git diff-files' '
82 echo 3 >>c &&
83 test_expect_code 1 git diff-files --quiet >cnt &&
84 test_line_count = 0 cnt
87 test_expect_success 'git diff-index --cached HEAD' '
88 git update-index c &&
89 test_expect_code 1 git diff-index --quiet --cached HEAD >cnt &&
90 test_line_count = 0 cnt
93 test_expect_success 'git diff, one file outside repo' '
95 cd test-outside/repo &&
96 test_expect_code 0 git diff --quiet a ../non/git/matching-file &&
97 test_expect_code 1 git diff --quiet a ../non/git/extra-space
101 test_expect_success 'git diff, both files outside repo' '
103 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
104 export GIT_CEILING_DIRECTORIES &&
105 cd test-outside/non/git &&
106 test_expect_code 0 git diff --quiet a matching-file &&
107 test_expect_code 1 git diff --quiet a extra-space
111 test_expect_success 'git diff --ignore-space-at-eol, one file outside repo' '
113 cd test-outside/repo &&
114 test_expect_code 0 git diff --quiet --ignore-space-at-eol a ../non/git/trailing-space &&
115 test_expect_code 1 git diff --quiet --ignore-space-at-eol a ../non/git/extra-space
119 test_expect_success 'git diff --ignore-space-at-eol, both files outside repo' '
121 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
122 export GIT_CEILING_DIRECTORIES &&
123 cd test-outside/non/git &&
124 test_expect_code 0 git diff --quiet --ignore-space-at-eol a trailing-space &&
125 test_expect_code 1 git diff --quiet --ignore-space-at-eol a extra-space
129 test_expect_success 'git diff --ignore-all-space, one file outside repo' '
131 cd test-outside/repo &&
132 test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/trailing-space &&
133 test_expect_code 0 git diff --quiet --ignore-all-space a ../non/git/extra-space &&
134 test_expect_code 1 git diff --quiet --ignore-all-space a ../non/git/never-match
138 test_expect_success 'git diff --ignore-all-space, both files outside repo' '
140 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/test-outside" &&
141 export GIT_CEILING_DIRECTORIES &&
142 cd test-outside/non/git &&
143 test_expect_code 0 git diff --quiet --ignore-all-space a trailing-space &&
144 test_expect_code 0 git diff --quiet --ignore-all-space a extra-space &&
145 test_expect_code 1 git diff --quiet --ignore-all-space a never-match
149 test_expect_success 'git diff --quiet ignores stat-change only entries' '
150 test-chmtime +10 a &&
151 echo modified >>b &&
152 test_expect_code 1 git diff --quiet
155 test_expect_success 'git diff --quiet on a path that need conversion' '
156 echo "crlf.txt text=auto" >.gitattributes &&
157 printf "Hello\r\nWorld\r\n" >crlf.txt &&
158 git add .gitattributes crlf.txt &&
160 printf "Hello\r\nWorld\n" >crlf.txt &&
161 git diff --quiet crlf.txt
164 test_done