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