]>
Commit | Line | Data |
---|---|---|
3c2f75b5 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Various diff formatting options' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
a40d384c JH |
10 | LF=' |
11 | ' | |
12 | ||
3c2f75b5 JH |
13 | test_expect_success setup ' |
14 | ||
15 | GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && | |
16 | GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" && | |
17 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
18 | ||
19 | mkdir dir && | |
3cb56738 | 20 | mkdir dir2 && |
3c2f75b5 JH |
21 | for i in 1 2 3; do echo $i; done >file0 && |
22 | for i in A B; do echo $i; done >dir/sub && | |
23 | cat file0 >file2 && | |
24 | git add file0 file2 dir/sub && | |
25 | git commit -m Initial && | |
26 | ||
27 | git branch initial && | |
28 | git branch side && | |
29 | ||
30 | GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" && | |
31 | GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" && | |
32 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
33 | ||
34 | for i in 4 5 6; do echo $i; done >>file0 && | |
35 | for i in C D; do echo $i; done >>dir/sub && | |
36 | rm -f file2 && | |
37 | git update-index --remove file0 file2 dir/sub && | |
a40d384c | 38 | git commit -m "Second${LF}${LF}This is the second commit." && |
3c2f75b5 JH |
39 | |
40 | GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" && | |
41 | GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" && | |
42 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
43 | ||
44 | for i in A B C; do echo $i; done >file1 && | |
45 | git add file1 && | |
46 | for i in E F; do echo $i; done >>dir/sub && | |
47 | git update-index dir/sub && | |
48 | git commit -m Third && | |
49 | ||
50 | GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" && | |
51 | GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" && | |
52 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
53 | ||
54 | git checkout side && | |
55 | for i in A B C; do echo $i; done >>file0 && | |
56 | for i in 1 2; do echo $i; done >>dir/sub && | |
57 | cat dir/sub >file3 && | |
58 | git add file3 && | |
59 | git update-index file0 dir/sub && | |
60 | git commit -m Side && | |
61 | ||
62 | GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" && | |
63 | GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" && | |
64 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
65 | ||
66 | git checkout master && | |
67 | git pull -s ours . side && | |
68 | ||
69 | GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" && | |
70 | GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" && | |
71 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
72 | ||
73 | for i in A B C; do echo $i; done >>file0 && | |
74 | for i in 1 2; do echo $i; done >>dir/sub && | |
75 | git update-index file0 dir/sub && | |
76 | ||
d61027b2 MS |
77 | mkdir dir3 && |
78 | cp dir/sub dir3/sub && | |
79 | test-chmtime +1 dir3/sub && | |
80 | ||
e0d10e1c | 81 | git config log.showroot false && |
8ff99e74 | 82 | git commit --amend && |
204f01a2 JH |
83 | |
84 | GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" && | |
85 | GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" && | |
86 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
87 | git checkout -b rearrange initial && | |
88 | for i in B A; do echo $i; done >dir/sub && | |
89 | git add dir/sub && | |
90 | git commit -m "Rearranged lines in dir/sub" && | |
91 | git checkout master && | |
92 | ||
5404c116 MM |
93 | git config diff.renames false && |
94 | ||
3c2f75b5 JH |
95 | git show-branch |
96 | ' | |
97 | ||
98 | : <<\EOF | |
99 | ! [initial] Initial | |
100 | * [master] Merge branch 'side' | |
204f01a2 JH |
101 | ! [rearrange] Rearranged lines in dir/sub |
102 | ! [side] Side | |
103 | ---- | |
104 | + [rearrange] Rearranged lines in dir/sub | |
105 | - [master] Merge branch 'side' | |
106 | * + [side] Side | |
107 | * [master^] Third | |
108 | * [master~2] Second | |
109 | +*++ [initial] Initial | |
3c2f75b5 JH |
110 | EOF |
111 | ||
4ff03347 | 112 | V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g') |
3c2f75b5 JH |
113 | while read cmd |
114 | do | |
115 | case "$cmd" in | |
116 | '' | '#'*) continue ;; | |
117 | esac | |
4ff03347 EP |
118 | test=$(echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g') |
119 | pfx=$(printf "%04d" $test_count) | |
bfdbee98 | 120 | expect="$TEST_DIRECTORY/t4013/diff.$test" |
3c2f75b5 JH |
121 | actual="$pfx-diff.$test" |
122 | ||
123 | test_expect_success "git $cmd" ' | |
124 | { | |
125 | echo "\$ git $cmd" | |
6c7f4ceb JH |
126 | git $cmd | |
127 | sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \ | |
33ee4cfb | 128 | -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/" |
3c2f75b5 JH |
129 | echo "\$" |
130 | } >"$actual" && | |
131 | if test -f "$expect" | |
132 | then | |
6dd88832 JN |
133 | case $cmd in |
134 | *format-patch* | *-stat*) | |
135 | test_i18ncmp "$expect" "$actual";; | |
136 | *) | |
137 | test_cmp "$expect" "$actual";; | |
138 | esac && | |
3c2f75b5 JH |
139 | rm -f "$actual" |
140 | else | |
141 | # this is to help developing new tests. | |
142 | cp "$actual" "$expect" | |
143 | false | |
144 | fi | |
145 | ' | |
146 | done <<\EOF | |
147 | diff-tree initial | |
148 | diff-tree -r initial | |
149 | diff-tree -r --abbrev initial | |
150 | diff-tree -r --abbrev=4 initial | |
151 | diff-tree --root initial | |
152 | diff-tree --root --abbrev initial | |
153 | diff-tree --root -r initial | |
154 | diff-tree --root -r --abbrev initial | |
155 | diff-tree --root -r --abbrev=4 initial | |
156 | diff-tree -p initial | |
157 | diff-tree --root -p initial | |
158 | diff-tree --patch-with-stat initial | |
159 | diff-tree --root --patch-with-stat initial | |
160 | diff-tree --patch-with-raw initial | |
161 | diff-tree --root --patch-with-raw initial | |
162 | ||
163 | diff-tree --pretty initial | |
164 | diff-tree --pretty --root initial | |
165 | diff-tree --pretty -p initial | |
166 | diff-tree --pretty --stat initial | |
167 | diff-tree --pretty --summary initial | |
168 | diff-tree --pretty --stat --summary initial | |
169 | diff-tree --pretty --root -p initial | |
170 | diff-tree --pretty --root --stat initial | |
026625e7 JH |
171 | # improved by Timo's patch |
172 | diff-tree --pretty --root --summary initial | |
173 | # improved by Timo's patch | |
174 | diff-tree --pretty --root --summary -r initial | |
3c2f75b5 JH |
175 | diff-tree --pretty --root --stat --summary initial |
176 | diff-tree --pretty --patch-with-stat initial | |
177 | diff-tree --pretty --root --patch-with-stat initial | |
178 | diff-tree --pretty --patch-with-raw initial | |
179 | diff-tree --pretty --root --patch-with-raw initial | |
180 | ||
181 | diff-tree --pretty=oneline initial | |
182 | diff-tree --pretty=oneline --root initial | |
183 | diff-tree --pretty=oneline -p initial | |
184 | diff-tree --pretty=oneline --root -p initial | |
185 | diff-tree --pretty=oneline --patch-with-stat initial | |
026625e7 | 186 | # improved by Timo's patch |
3c2f75b5 JH |
187 | diff-tree --pretty=oneline --root --patch-with-stat initial |
188 | diff-tree --pretty=oneline --patch-with-raw initial | |
189 | diff-tree --pretty=oneline --root --patch-with-raw initial | |
190 | ||
191 | diff-tree --pretty side | |
192 | diff-tree --pretty -p side | |
193 | diff-tree --pretty --patch-with-stat side | |
194 | ||
195 | diff-tree master | |
196 | diff-tree -p master | |
197 | diff-tree -p -m master | |
198 | diff-tree -c master | |
199 | diff-tree -c --abbrev master | |
200 | diff-tree --cc master | |
47979d5d JH |
201 | # stat only should show the diffstat with the first parent |
202 | diff-tree -c --stat master | |
203 | diff-tree --cc --stat master | |
204 | diff-tree -c --stat --summary master | |
205 | diff-tree --cc --stat --summary master | |
206 | # stat summary should show the diffstat and summary with the first parent | |
207 | diff-tree -c --stat --summary side | |
208 | diff-tree --cc --stat --summary side | |
026625e7 JH |
209 | # improved by Timo's patch |
210 | diff-tree --cc --patch-with-stat master | |
211 | # improved by Timo's patch | |
47979d5d JH |
212 | diff-tree --cc --patch-with-stat --summary master |
213 | # this is correct | |
214 | diff-tree --cc --patch-with-stat --summary side | |
3c2f75b5 JH |
215 | |
216 | log master | |
217 | log -p master | |
218 | log --root master | |
219 | log --root -p master | |
220 | log --patch-with-stat master | |
221 | log --root --patch-with-stat master | |
47979d5d | 222 | log --root --patch-with-stat --summary master |
026625e7 | 223 | # improved by Timo's patch |
47979d5d | 224 | log --root -c --patch-with-stat --summary master |
026625e7 | 225 | # improved by Timo's patch |
47979d5d | 226 | log --root --cc --patch-with-stat --summary master |
126f431a JH |
227 | log -p --first-parent master |
228 | log -m -p --first-parent master | |
229 | log -m -p master | |
3c2f75b5 | 230 | log -SF master |
dea007fb | 231 | log -S F master |
47979d5d | 232 | log -SF -p master |
251df09b MM |
233 | log -SF master --max-count=0 |
234 | log -SF master --max-count=1 | |
235 | log -SF master --max-count=2 | |
bf1dfc31 JH |
236 | log -GF master |
237 | log -GF -p master | |
238 | log -GF -p --pickaxe-all master | |
28fd76bd | 239 | log --decorate --all |
33e7018c | 240 | log --decorate=full --all |
3c2f75b5 | 241 | |
fcbc6efc TR |
242 | rev-list --parents HEAD |
243 | rev-list --children HEAD | |
3c2f75b5 JH |
244 | |
245 | whatchanged master | |
246 | whatchanged -p master | |
247 | whatchanged --root master | |
248 | whatchanged --root -p master | |
249 | whatchanged --patch-with-stat master | |
250 | whatchanged --root --patch-with-stat master | |
251 | whatchanged --root --patch-with-stat --summary master | |
026625e7 | 252 | # improved by Timo's patch |
47979d5d | 253 | whatchanged --root -c --patch-with-stat --summary master |
026625e7 | 254 | # improved by Timo's patch |
47979d5d | 255 | whatchanged --root --cc --patch-with-stat --summary master |
3c2f75b5 | 256 | whatchanged -SF master |
47979d5d | 257 | whatchanged -SF -p master |
3c2f75b5 JH |
258 | |
259 | log --patch-with-stat master -- dir/ | |
260 | whatchanged --patch-with-stat master -- dir/ | |
47979d5d JH |
261 | log --patch-with-stat --summary master -- dir/ |
262 | whatchanged --patch-with-stat --summary master -- dir/ | |
3c2f75b5 JH |
263 | |
264 | show initial | |
265 | show --root initial | |
266 | show side | |
267 | show master | |
b4490059 | 268 | show -c master |
2bf65873 JH |
269 | show -m master |
270 | show --first-parent master | |
3c2f75b5 JH |
271 | show --stat side |
272 | show --stat --summary side | |
273 | show --patch-with-stat side | |
274 | show --patch-with-raw side | |
275 | show --patch-with-stat --summary side | |
276 | ||
d410e43b JH |
277 | format-patch --stdout initial..side |
278 | format-patch --stdout initial..master^ | |
279 | format-patch --stdout initial..master | |
a567fdcb BG |
280 | format-patch --stdout --no-numbered initial..master |
281 | format-patch --stdout --numbered initial..master | |
d410e43b | 282 | format-patch --attach --stdout initial..side |
108dab28 | 283 | format-patch --attach --stdout --suffix=.diff initial..side |
d410e43b JH |
284 | format-patch --attach --stdout initial..master^ |
285 | format-patch --attach --stdout initial..master | |
c112f689 JS |
286 | format-patch --inline --stdout initial..side |
287 | format-patch --inline --stdout initial..master^ | |
747e2505 | 288 | format-patch --inline --stdout --numbered-files initial..master |
a567fdcb | 289 | format-patch --inline --stdout initial..master |
171ddd91 | 290 | format-patch --inline --stdout --subject-prefix=TESTCASE initial..master |
dbd21447 AR |
291 | config format.subjectprefix DIFFERENT_PREFIX |
292 | format-patch --inline --stdout initial..master^^ | |
a5a27c79 | 293 | format-patch --stdout --cover-letter -n initial..master^ |
d410e43b | 294 | |
b319b02e JH |
295 | diff --abbrev initial..side |
296 | diff -r initial..side | |
297 | diff --stat initial..side | |
298 | diff -r --stat initial..side | |
299 | diff initial..side | |
300 | diff --patch-with-stat initial..side | |
301 | diff --patch-with-raw initial..side | |
302 | diff --patch-with-stat -r initial..side | |
303 | diff --patch-with-raw -r initial..side | |
3cb56738 | 304 | diff --name-status dir2 dir |
0569e9b8 | 305 | diff --no-index --name-status dir2 dir |
e423ffd8 | 306 | diff --no-index --name-status -- dir2 dir |
d61027b2 | 307 | diff --no-index dir dir3 |
b75271d9 | 308 | diff master master^ side |
660e113c JK |
309 | # Can't use spaces... |
310 | diff --line-prefix=abc master master^ side | |
f37bfb7a | 311 | diff --dirstat master~1 master~2 |
204f01a2 | 312 | diff --dirstat initial rearrange |
0133dab7 | 313 | diff --dirstat-by-file initial rearrange |
43d1948b JB |
314 | # No-index --abbrev and --no-abbrev |
315 | diff --raw initial | |
316 | diff --raw --abbrev=4 initial | |
317 | diff --raw --no-abbrev initial | |
318 | diff --no-index --raw dir2 dir | |
319 | diff --no-index --raw --abbrev=4 dir2 dir | |
320 | diff --no-index --raw --no-abbrev dir2 dir | |
3c2f75b5 JH |
321 | EOF |
322 | ||
dea007fb MM |
323 | test_expect_success 'log -S requires an argument' ' |
324 | test_must_fail git log -S | |
325 | ' | |
326 | ||
a2b7a3b3 NTND |
327 | test_expect_success 'diff --cached on unborn branch' ' |
328 | echo ref: refs/heads/unborn >.git/HEAD && | |
329 | git diff --cached >result && | |
330 | test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result | |
331 | ' | |
332 | ||
333 | test_expect_success 'diff --cached -- file on unborn branch' ' | |
334 | git diff --cached -- file0 >result && | |
335 | test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result | |
336 | ' | |
660e113c JK |
337 | test_expect_success 'diff --line-prefix with spaces' ' |
338 | git diff --line-prefix="| | | " --cached -- file0 >result && | |
339 | test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" result | |
340 | ' | |
a2b7a3b3 | 341 | |
d299e9e5 JK |
342 | test_expect_success 'diff-tree --stdin with log formatting' ' |
343 | cat >expect <<-\EOF && | |
344 | Side | |
345 | Third | |
346 | Second | |
347 | EOF | |
348 | git rev-list master | git diff-tree --stdin --format=%s -s >actual && | |
349 | test_cmp expect actual | |
350 | ' | |
351 | ||
3c2f75b5 | 352 | test_done |