]>
Commit | Line | Data |
---|---|---|
0c66d6be AR |
1 | #!/bin/sh |
2 | ||
3 | test_description='Return value of diffs' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' ' | |
8 | echo 1 >a && | |
9 | git add . && | |
10 | git commit -m first && | |
11 | echo 2 >b && | |
12 | git add . && | |
304970dd TH |
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 | |
28 | ) | |
0c66d6be AR |
29 | ' |
30 | ||
31 | test_expect_success 'git diff-tree HEAD^ HEAD' ' | |
c21fc9d0 JK |
32 | test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt && |
33 | test_line_count = 0 cnt | |
0c66d6be AR |
34 | ' |
35 | test_expect_success 'git diff-tree HEAD^ HEAD -- a' ' | |
c21fc9d0 JK |
36 | test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt && |
37 | test_line_count = 0 cnt | |
0c66d6be AR |
38 | ' |
39 | test_expect_success 'git diff-tree HEAD^ HEAD -- b' ' | |
c21fc9d0 JK |
40 | test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt && |
41 | test_line_count = 0 cnt | |
0c66d6be AR |
42 | ' |
43 | # this diff outputs one line: sha1 of the given head | |
44 | test_expect_success 'echo HEAD | git diff-tree --stdin' ' | |
c21fc9d0 JK |
45 | echo $(git rev-parse HEAD) | |
46 | test_expect_code 1 git diff-tree --quiet --stdin >cnt && | |
47 | test_line_count = 1 cnt | |
0c66d6be AR |
48 | ' |
49 | test_expect_success 'git diff-tree HEAD HEAD' ' | |
c21fc9d0 JK |
50 | test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt && |
51 | test_line_count = 0 cnt | |
0c66d6be AR |
52 | ' |
53 | test_expect_success 'git diff-files' ' | |
c21fc9d0 JK |
54 | test_expect_code 0 git diff-files --quiet >cnt && |
55 | test_line_count = 0 cnt | |
0c66d6be AR |
56 | ' |
57 | test_expect_success 'git diff-index --cached HEAD' ' | |
c21fc9d0 JK |
58 | test_expect_code 0 git diff-index --quiet --cached HEAD >cnt && |
59 | test_line_count = 0 cnt | |
0c66d6be AR |
60 | ' |
61 | test_expect_success 'git diff-index --cached HEAD^' ' | |
c21fc9d0 JK |
62 | test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt && |
63 | test_line_count = 0 cnt | |
0c66d6be AR |
64 | ' |
65 | test_expect_success 'git diff-index --cached HEAD^' ' | |
66 | echo text >>b && | |
67 | echo 3 >c && | |
c21fc9d0 JK |
68 | git add . && |
69 | test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt && | |
70 | test_line_count = 0 cnt | |
0c66d6be AR |
71 | ' |
72 | test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' ' | |
c21fc9d0 JK |
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 | |
0c66d6be AR |
76 | ' |
77 | test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' ' | |
c21fc9d0 JK |
78 | test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt && |
79 | test_line_count = 0 cnt | |
0c66d6be AR |
80 | ' |
81 | test_expect_success 'git diff-files' ' | |
c21fc9d0 JK |
82 | echo 3 >>c && |
83 | test_expect_code 1 git diff-files --quiet >cnt && | |
84 | test_line_count = 0 cnt | |
0c66d6be | 85 | ' |
c21fc9d0 | 86 | |
0c66d6be | 87 | test_expect_success 'git diff-index --cached HEAD' ' |
c21fc9d0 JK |
88 | git update-index c && |
89 | test_expect_code 1 git diff-index --quiet --cached HEAD >cnt && | |
90 | test_line_count = 0 cnt | |
0c66d6be AR |
91 | ' |
92 | ||
304970dd TH |
93 | test_expect_success 'git diff, one file outside repo' ' |
94 | ( | |
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 | |
98 | ) | |
99 | ' | |
100 | ||
101 | test_expect_success 'git diff, both files outside repo' ' | |
102 | ( | |
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 | |
108 | ) | |
109 | ' | |
110 | ||
111 | test_expect_success 'git diff --ignore-space-at-eol, one file outside repo' ' | |
112 | ( | |
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 | |
116 | ) | |
117 | ' | |
118 | ||
119 | test_expect_success 'git diff --ignore-space-at-eol, both files outside repo' ' | |
120 | ( | |
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 | |
126 | ) | |
127 | ' | |
128 | ||
129 | test_expect_success 'git diff --ignore-all-space, one file outside repo' ' | |
130 | ( | |
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 | |
135 | ) | |
136 | ' | |
137 | ||
138 | test_expect_success 'git diff --ignore-all-space, both files outside repo' ' | |
139 | ( | |
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 | |
146 | ) | |
147 | ' | |
148 | ||
f34b205f | 149 | test_expect_success 'git diff --quiet ignores stat-change only entries' ' |
0e496492 | 150 | test-tool chmtime +10 a && |
f34b205f NTND |
151 | echo modified >>b && |
152 | test_expect_code 1 git diff --quiet | |
153 | ' | |
154 | ||
12426e11 JH |
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 && | |
159 | ||
160 | printf "Hello\r\nWorld\n" >crlf.txt && | |
161 | git diff --quiet crlf.txt | |
162 | ' | |
163 | ||
0c66d6be | 164 | test_done |