]>
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 | ||
334afbc7 JS |
8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master |
9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME | |
10 | ||
3c2f75b5 | 11 | . ./test-lib.sh |
296d4a94 | 12 | . "$TEST_DIRECTORY"/diff-lib.sh |
3c2f75b5 JH |
13 | |
14 | test_expect_success setup ' | |
15 | ||
16 | GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && | |
17 | GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" && | |
18 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
19 | ||
20 | mkdir dir && | |
3cb56738 | 21 | mkdir dir2 && |
3c2f75b5 JH |
22 | for i in 1 2 3; do echo $i; done >file0 && |
23 | for i in A B; do echo $i; done >dir/sub && | |
24 | cat file0 >file2 && | |
25 | git add file0 file2 dir/sub && | |
26 | git commit -m Initial && | |
27 | ||
28 | git branch initial && | |
29 | git branch side && | |
30 | ||
31 | GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" && | |
32 | GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" && | |
33 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
34 | ||
35 | for i in 4 5 6; do echo $i; done >>file0 && | |
36 | for i in C D; do echo $i; done >>dir/sub && | |
37 | rm -f file2 && | |
38 | git update-index --remove file0 file2 dir/sub && | |
a40d384c | 39 | git commit -m "Second${LF}${LF}This is the second commit." && |
3c2f75b5 JH |
40 | |
41 | GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" && | |
42 | GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" && | |
43 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
44 | ||
45 | for i in A B C; do echo $i; done >file1 && | |
46 | git add file1 && | |
47 | for i in E F; do echo $i; done >>dir/sub && | |
48 | git update-index dir/sub && | |
49 | git commit -m Third && | |
50 | ||
51 | GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" && | |
52 | GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" && | |
53 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
54 | ||
55 | git checkout side && | |
56 | for i in A B C; do echo $i; done >>file0 && | |
57 | for i in 1 2; do echo $i; done >>dir/sub && | |
58 | cat dir/sub >file3 && | |
59 | git add file3 && | |
60 | git update-index file0 dir/sub && | |
61 | git commit -m Side && | |
62 | ||
63 | GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" && | |
64 | GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" && | |
65 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
66 | ||
67 | git checkout master && | |
68 | git pull -s ours . side && | |
69 | ||
70 | GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" && | |
71 | GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" && | |
72 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
73 | ||
74 | for i in A B C; do echo $i; done >>file0 && | |
75 | for i in 1 2; do echo $i; done >>dir/sub && | |
76 | git update-index file0 dir/sub && | |
77 | ||
d61027b2 MS |
78 | mkdir dir3 && |
79 | cp dir/sub dir3/sub && | |
0e496492 | 80 | test-tool chmtime +1 dir3/sub && |
d61027b2 | 81 | |
e0d10e1c | 82 | git config log.showroot false && |
8ff99e74 | 83 | git commit --amend && |
204f01a2 JH |
84 | |
85 | GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" && | |
86 | GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" && | |
87 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
88 | git checkout -b rearrange initial && | |
89 | for i in B A; do echo $i; done >dir/sub && | |
90 | git add dir/sub && | |
91 | git commit -m "Rearranged lines in dir/sub" && | |
92 | git checkout master && | |
93 | ||
58aaced4 SB |
94 | GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" && |
95 | GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" && | |
96 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
97 | git checkout -b mode initial && | |
98 | git update-index --chmod=+x file0 && | |
99 | git commit -m "update mode" && | |
100 | git checkout -f master && | |
101 | ||
5778b22b TB |
102 | GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" && |
103 | GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" && | |
104 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
105 | git checkout -b note initial && | |
106 | git update-index --chmod=+x file2 && | |
107 | git commit -m "update mode (file2)" && | |
108 | git notes add -m "note" && | |
109 | git checkout -f master && | |
110 | ||
04b19fca JK |
111 | # Same merge as master, but with parents reversed. Hide it in a |
112 | # pseudo-ref to avoid impacting tests with --all. | |
113 | commit=$(echo reverse | | |
114 | git commit-tree -p master^2 -p master^1 master^{tree}) && | |
115 | git update-ref REVERSE $commit && | |
116 | ||
5404c116 MM |
117 | git config diff.renames false && |
118 | ||
3c2f75b5 JH |
119 | git show-branch |
120 | ' | |
121 | ||
122 | : <<\EOF | |
123 | ! [initial] Initial | |
21531927 | 124 | * [master] Merge branch 'side' |
204f01a2 JH |
125 | ! [rearrange] Rearranged lines in dir/sub |
126 | ! [side] Side | |
127 | ---- | |
128 | + [rearrange] Rearranged lines in dir/sub | |
21531927 | 129 | - [master] Merge branch 'side' |
204f01a2 JH |
130 | * + [side] Side |
131 | * [master^] Third | |
132 | * [master~2] Second | |
133 | +*++ [initial] Initial | |
3c2f75b5 JH |
134 | EOF |
135 | ||
72f936b1 | 136 | process_diffs () { |
fc7e73d7 | 137 | perl -e ' |
138 | my $oid_length = length($ARGV[0]); | |
139 | my $x40 = "[0-9a-f]{40}"; | |
140 | my $xab = "[0-9a-f]{4,16}"; | |
141 | my $orx = "[0-9a-f]" x $oid_length; | |
142 | ||
143 | sub munge_oid { | |
144 | my ($oid) = @_; | |
145 | my $x; | |
146 | ||
147 | return "" unless length $oid; | |
148 | ||
149 | if ($oid =~ /^(100644|100755|120000)$/) { | |
150 | return $oid; | |
151 | } | |
152 | ||
153 | if ($oid =~ /^0*$/) { | |
154 | $x = "0"; | |
155 | } else { | |
156 | $x = "f"; | |
157 | } | |
158 | ||
159 | if (length($oid) == 40) { | |
160 | return $x x $oid_length; | |
161 | } else { | |
162 | return $x x length($oid); | |
163 | } | |
164 | } | |
165 | ||
166 | while (<STDIN>) { | |
167 | s/($orx)/munge_oid($1)/ge; | |
168 | s/From ($x40)( |\))/"From " . munge_oid($1) . $2/ge; | |
169 | s/commit ($x40)($| \(from )($x40?)/"commit " . munge_oid($1) . $2 . munge_oid($3)/ge; | |
170 | s/\b($x40)( |\.\.|$)/munge_oid($1) . $2/ge; | |
171 | s/^($x40)($| )/munge_oid($1) . $2/e; | |
172 | s/($xab)(\.\.|,| |\.\.\.|$)/munge_oid($1) . $2/ge; | |
173 | print; | |
174 | } | |
175 | ' "$ZERO_OID" <"$1" | |
72f936b1 | 176 | } |
177 | ||
4ff03347 | 178 | V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g') |
b4c02c30 | 179 | while read magic cmd |
3c2f75b5 | 180 | do |
b4c02c30 AR |
181 | case "$magic" in |
182 | '' | '#'*) | |
183 | continue ;; | |
184 | :*) | |
185 | magic=${magic#:} | |
186 | label="$magic-$cmd" | |
187 | case "$magic" in | |
188 | noellipses) ;; | |
189 | *) | |
165293af | 190 | BUG "unknown magic $magic" ;; |
b4c02c30 AR |
191 | esac ;; |
192 | *) | |
193 | cmd="$magic $cmd" magic= | |
194 | label="$cmd" ;; | |
3c2f75b5 | 195 | esac |
b4c02c30 | 196 | test=$(echo "$label" | sed -e 's|[/ ][/ ]*|_|g') |
4ff03347 | 197 | pfx=$(printf "%04d" $test_count) |
bfdbee98 | 198 | expect="$TEST_DIRECTORY/t4013/diff.$test" |
3c2f75b5 JH |
199 | actual="$pfx-diff.$test" |
200 | ||
de231e57 | 201 | test_expect_success "git $cmd # magic is ${magic:-(not used)}" ' |
3c2f75b5 | 202 | { |
b4c02c30 AR |
203 | echo "$ git $cmd" |
204 | case "$magic" in | |
205 | "") | |
206 | GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;; | |
207 | noellipses) | |
208 | git $cmd ;; | |
209 | esac | | |
6c7f4ceb | 210 | sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \ |
33ee4cfb | 211 | -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/" |
3c2f75b5 JH |
212 | echo "\$" |
213 | } >"$actual" && | |
214 | if test -f "$expect" | |
215 | then | |
72f936b1 | 216 | process_diffs "$actual" >actual && |
217 | process_diffs "$expect" >expect && | |
6dd88832 JN |
218 | case $cmd in |
219 | *format-patch* | *-stat*) | |
72f936b1 | 220 | test_i18ncmp expect actual;; |
6dd88832 | 221 | *) |
72f936b1 | 222 | test_cmp expect actual;; |
6dd88832 | 223 | esac && |
72f936b1 | 224 | rm -f "$actual" actual expect |
3c2f75b5 JH |
225 | else |
226 | # this is to help developing new tests. | |
227 | cp "$actual" "$expect" | |
228 | false | |
229 | fi | |
230 | ' | |
231 | done <<\EOF | |
232 | diff-tree initial | |
233 | diff-tree -r initial | |
234 | diff-tree -r --abbrev initial | |
235 | diff-tree -r --abbrev=4 initial | |
236 | diff-tree --root initial | |
237 | diff-tree --root --abbrev initial | |
c2f1d398 | 238 | :noellipses diff-tree --root --abbrev initial |
3c2f75b5 JH |
239 | diff-tree --root -r initial |
240 | diff-tree --root -r --abbrev initial | |
c2f1d398 | 241 | :noellipses diff-tree --root -r --abbrev initial |
3c2f75b5 | 242 | diff-tree --root -r --abbrev=4 initial |
c2f1d398 | 243 | :noellipses diff-tree --root -r --abbrev=4 initial |
3c2f75b5 JH |
244 | diff-tree -p initial |
245 | diff-tree --root -p initial | |
3046c7f6 ĐTCD |
246 | diff-tree --root -p --abbrev=10 initial |
247 | diff-tree --root -p --full-index initial | |
248 | diff-tree --root -p --full-index --abbrev=10 initial | |
3c2f75b5 JH |
249 | diff-tree --patch-with-stat initial |
250 | diff-tree --root --patch-with-stat initial | |
251 | diff-tree --patch-with-raw initial | |
252 | diff-tree --root --patch-with-raw initial | |
253 | ||
254 | diff-tree --pretty initial | |
255 | diff-tree --pretty --root initial | |
256 | diff-tree --pretty -p initial | |
257 | diff-tree --pretty --stat initial | |
258 | diff-tree --pretty --summary initial | |
259 | diff-tree --pretty --stat --summary initial | |
260 | diff-tree --pretty --root -p initial | |
261 | diff-tree --pretty --root --stat initial | |
026625e7 JH |
262 | # improved by Timo's patch |
263 | diff-tree --pretty --root --summary initial | |
264 | # improved by Timo's patch | |
265 | diff-tree --pretty --root --summary -r initial | |
3c2f75b5 JH |
266 | diff-tree --pretty --root --stat --summary initial |
267 | diff-tree --pretty --patch-with-stat initial | |
268 | diff-tree --pretty --root --patch-with-stat initial | |
269 | diff-tree --pretty --patch-with-raw initial | |
270 | diff-tree --pretty --root --patch-with-raw initial | |
271 | ||
272 | diff-tree --pretty=oneline initial | |
273 | diff-tree --pretty=oneline --root initial | |
274 | diff-tree --pretty=oneline -p initial | |
275 | diff-tree --pretty=oneline --root -p initial | |
276 | diff-tree --pretty=oneline --patch-with-stat initial | |
026625e7 | 277 | # improved by Timo's patch |
3c2f75b5 JH |
278 | diff-tree --pretty=oneline --root --patch-with-stat initial |
279 | diff-tree --pretty=oneline --patch-with-raw initial | |
280 | diff-tree --pretty=oneline --root --patch-with-raw initial | |
281 | ||
282 | diff-tree --pretty side | |
283 | diff-tree --pretty -p side | |
284 | diff-tree --pretty --patch-with-stat side | |
285 | ||
58aaced4 SB |
286 | diff-tree initial mode |
287 | diff-tree --stat initial mode | |
288 | diff-tree --summary initial mode | |
289 | ||
3c2f75b5 JH |
290 | diff-tree master |
291 | diff-tree -p master | |
292 | diff-tree -p -m master | |
293 | diff-tree -c master | |
294 | diff-tree -c --abbrev master | |
c2f1d398 | 295 | :noellipses diff-tree -c --abbrev master |
3c2f75b5 | 296 | diff-tree --cc master |
47979d5d JH |
297 | # stat only should show the diffstat with the first parent |
298 | diff-tree -c --stat master | |
299 | diff-tree --cc --stat master | |
300 | diff-tree -c --stat --summary master | |
301 | diff-tree --cc --stat --summary master | |
302 | # stat summary should show the diffstat and summary with the first parent | |
303 | diff-tree -c --stat --summary side | |
304 | diff-tree --cc --stat --summary side | |
8290faa0 | 305 | diff-tree --cc --shortstat master |
04b19fca | 306 | diff-tree --cc --summary REVERSE |
026625e7 JH |
307 | # improved by Timo's patch |
308 | diff-tree --cc --patch-with-stat master | |
309 | # improved by Timo's patch | |
47979d5d JH |
310 | diff-tree --cc --patch-with-stat --summary master |
311 | # this is correct | |
312 | diff-tree --cc --patch-with-stat --summary side | |
3c2f75b5 JH |
313 | |
314 | log master | |
315 | log -p master | |
316 | log --root master | |
317 | log --root -p master | |
318 | log --patch-with-stat master | |
319 | log --root --patch-with-stat master | |
47979d5d | 320 | log --root --patch-with-stat --summary master |
026625e7 | 321 | # improved by Timo's patch |
47979d5d | 322 | log --root -c --patch-with-stat --summary master |
026625e7 | 323 | # improved by Timo's patch |
47979d5d | 324 | log --root --cc --patch-with-stat --summary master |
6fae74b4 | 325 | log --no-diff-merges -p --first-parent master |
298889d3 SO |
326 | log --diff-merges=off -p --first-parent master |
327 | log --first-parent --diff-merges=off -p master | |
126f431a JH |
328 | log -p --first-parent master |
329 | log -m -p --first-parent master | |
330 | log -m -p master | |
3c2f75b5 | 331 | log -SF master |
dea007fb | 332 | log -S F master |
47979d5d | 333 | log -SF -p master |
251df09b MM |
334 | log -SF master --max-count=0 |
335 | log -SF master --max-count=1 | |
336 | log -SF master --max-count=2 | |
bf1dfc31 JH |
337 | log -GF master |
338 | log -GF -p master | |
339 | log -GF -p --pickaxe-all master | |
296d4a94 | 340 | log -IA -IB -I1 -I2 -p master |
28fd76bd | 341 | log --decorate --all |
33e7018c | 342 | log --decorate=full --all |
3c2f75b5 | 343 | |
fcbc6efc TR |
344 | rev-list --parents HEAD |
345 | rev-list --children HEAD | |
3c2f75b5 JH |
346 | |
347 | whatchanged master | |
c2f1d398 | 348 | :noellipses whatchanged master |
3c2f75b5 JH |
349 | whatchanged -p master |
350 | whatchanged --root master | |
c2f1d398 | 351 | :noellipses whatchanged --root master |
3c2f75b5 JH |
352 | whatchanged --root -p master |
353 | whatchanged --patch-with-stat master | |
354 | whatchanged --root --patch-with-stat master | |
355 | whatchanged --root --patch-with-stat --summary master | |
026625e7 | 356 | # improved by Timo's patch |
47979d5d | 357 | whatchanged --root -c --patch-with-stat --summary master |
026625e7 | 358 | # improved by Timo's patch |
47979d5d | 359 | whatchanged --root --cc --patch-with-stat --summary master |
3c2f75b5 | 360 | whatchanged -SF master |
c2f1d398 | 361 | :noellipses whatchanged -SF master |
47979d5d | 362 | whatchanged -SF -p master |
3c2f75b5 JH |
363 | |
364 | log --patch-with-stat master -- dir/ | |
365 | whatchanged --patch-with-stat master -- dir/ | |
47979d5d JH |
366 | log --patch-with-stat --summary master -- dir/ |
367 | whatchanged --patch-with-stat --summary master -- dir/ | |
3c2f75b5 JH |
368 | |
369 | show initial | |
370 | show --root initial | |
371 | show side | |
372 | show master | |
b4490059 | 373 | show -c master |
2bf65873 JH |
374 | show -m master |
375 | show --first-parent master | |
3c2f75b5 JH |
376 | show --stat side |
377 | show --stat --summary side | |
378 | show --patch-with-stat side | |
379 | show --patch-with-raw side | |
c2f1d398 | 380 | :noellipses show --patch-with-raw side |
3c2f75b5 JH |
381 | show --patch-with-stat --summary side |
382 | ||
d410e43b JH |
383 | format-patch --stdout initial..side |
384 | format-patch --stdout initial..master^ | |
385 | format-patch --stdout initial..master | |
a567fdcb BG |
386 | format-patch --stdout --no-numbered initial..master |
387 | format-patch --stdout --numbered initial..master | |
d410e43b | 388 | format-patch --attach --stdout initial..side |
108dab28 | 389 | format-patch --attach --stdout --suffix=.diff initial..side |
d410e43b JH |
390 | format-patch --attach --stdout initial..master^ |
391 | format-patch --attach --stdout initial..master | |
c112f689 JS |
392 | format-patch --inline --stdout initial..side |
393 | format-patch --inline --stdout initial..master^ | |
747e2505 | 394 | format-patch --inline --stdout --numbered-files initial..master |
a567fdcb | 395 | format-patch --inline --stdout initial..master |
171ddd91 | 396 | format-patch --inline --stdout --subject-prefix=TESTCASE initial..master |
dbd21447 AR |
397 | config format.subjectprefix DIFFERENT_PREFIX |
398 | format-patch --inline --stdout initial..master^^ | |
a5a27c79 | 399 | format-patch --stdout --cover-letter -n initial..master^ |
d410e43b | 400 | |
b319b02e | 401 | diff --abbrev initial..side |
8ef05193 NTND |
402 | diff -U initial..side |
403 | diff -U1 initial..side | |
b319b02e JH |
404 | diff -r initial..side |
405 | diff --stat initial..side | |
406 | diff -r --stat initial..side | |
407 | diff initial..side | |
408 | diff --patch-with-stat initial..side | |
409 | diff --patch-with-raw initial..side | |
c2f1d398 | 410 | :noellipses diff --patch-with-raw initial..side |
b319b02e JH |
411 | diff --patch-with-stat -r initial..side |
412 | diff --patch-with-raw -r initial..side | |
c2f1d398 | 413 | :noellipses diff --patch-with-raw -r initial..side |
3cb56738 | 414 | diff --name-status dir2 dir |
0569e9b8 | 415 | diff --no-index --name-status dir2 dir |
e423ffd8 | 416 | diff --no-index --name-status -- dir2 dir |
d61027b2 | 417 | diff --no-index dir dir3 |
b75271d9 | 418 | diff master master^ side |
660e113c JK |
419 | # Can't use spaces... |
420 | diff --line-prefix=abc master master^ side | |
f37bfb7a | 421 | diff --dirstat master~1 master~2 |
204f01a2 | 422 | diff --dirstat initial rearrange |
0133dab7 | 423 | diff --dirstat-by-file initial rearrange |
dac03b55 | 424 | diff --dirstat --cc master~1 master |
43d1948b JB |
425 | # No-index --abbrev and --no-abbrev |
426 | diff --raw initial | |
c2f1d398 | 427 | :noellipses diff --raw initial |
43d1948b | 428 | diff --raw --abbrev=4 initial |
c2f1d398 | 429 | :noellipses diff --raw --abbrev=4 initial |
43d1948b JB |
430 | diff --raw --no-abbrev initial |
431 | diff --no-index --raw dir2 dir | |
c2f1d398 | 432 | :noellipses diff --no-index --raw dir2 dir |
43d1948b | 433 | diff --no-index --raw --abbrev=4 dir2 dir |
c2f1d398 | 434 | :noellipses diff --no-index --raw --abbrev=4 dir2 dir |
43d1948b | 435 | diff --no-index --raw --no-abbrev dir2 dir |
ddf88fa6 NTND |
436 | |
437 | diff-tree --pretty --root --stat --compact-summary initial | |
438 | diff-tree --pretty -R --root --stat --compact-summary initial | |
5778b22b TB |
439 | diff-tree --pretty note |
440 | diff-tree --pretty --notes note | |
441 | diff-tree --format=%N note | |
ddf88fa6 NTND |
442 | diff-tree --stat --compact-summary initial mode |
443 | diff-tree -R --stat --compact-summary initial mode | |
3c2f75b5 JH |
444 | EOF |
445 | ||
dea007fb MM |
446 | test_expect_success 'log -S requires an argument' ' |
447 | test_must_fail git log -S | |
448 | ' | |
449 | ||
a2b7a3b3 NTND |
450 | test_expect_success 'diff --cached on unborn branch' ' |
451 | echo ref: refs/heads/unborn >.git/HEAD && | |
452 | git diff --cached >result && | |
72f936b1 | 453 | process_diffs result >actual && |
454 | process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached" >expected && | |
455 | test_cmp expected actual | |
a2b7a3b3 NTND |
456 | ' |
457 | ||
458 | test_expect_success 'diff --cached -- file on unborn branch' ' | |
459 | git diff --cached -- file0 >result && | |
72f936b1 | 460 | process_diffs result >actual && |
461 | process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" >expected && | |
462 | test_cmp expected actual | |
a2b7a3b3 | 463 | ' |
660e113c JK |
464 | test_expect_success 'diff --line-prefix with spaces' ' |
465 | git diff --line-prefix="| | | " --cached -- file0 >result && | |
72f936b1 | 466 | process_diffs result >actual && |
467 | process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" >expected && | |
468 | test_cmp expected actual | |
660e113c | 469 | ' |
a2b7a3b3 | 470 | |
d299e9e5 JK |
471 | test_expect_success 'diff-tree --stdin with log formatting' ' |
472 | cat >expect <<-\EOF && | |
473 | Side | |
474 | Third | |
475 | Second | |
476 | EOF | |
477 | git rev-list master | git diff-tree --stdin --format=%s -s >actual && | |
478 | test_cmp expect actual | |
479 | ' | |
480 | ||
296d4a94 MK |
481 | test_expect_success 'diff -I<regex>: setup' ' |
482 | git checkout master && | |
483 | test_seq 50 >file0 && | |
484 | git commit -m "Set up -I<regex> test file" file0 && | |
485 | test_seq 50 | sed -e "s/13/ten and three/" -e "/7\$/d" >file0 && | |
486 | echo >>file0 | |
487 | ' | |
488 | test_expect_success 'diff -I<regex>' ' | |
489 | git diff --ignore-blank-lines -I"ten.*e" -I"^[124-9]" >actual && | |
490 | cat >expect <<-\EOF && | |
491 | diff --git a/file0 b/file0 | |
492 | --- a/file0 | |
493 | +++ b/file0 | |
494 | @@ -34,7 +31,6 @@ | |
495 | 34 | |
496 | 35 | |
497 | 36 | |
498 | -37 | |
499 | 38 | |
500 | 39 | |
501 | 40 | |
502 | EOF | |
503 | compare_diff_patch expect actual | |
504 | ' | |
505 | ||
506 | test_expect_success 'diff -I<regex> --stat' ' | |
507 | git diff --stat --ignore-blank-lines -I"ten.*e" -I"^[124-9]" >actual && | |
508 | cat >expect <<-\EOF && | |
509 | file0 | 1 - | |
510 | 1 file changed, 1 deletion(-) | |
511 | EOF | |
512 | test_cmp expect actual | |
513 | ' | |
514 | ||
515 | test_expect_success 'diff -I<regex>: detect malformed regex' ' | |
516 | test_expect_code 129 git diff --ignore-matching-lines="^[124-9" 2>error && | |
517 | test_i18ngrep "invalid regex given to -I: " error | |
518 | ' | |
519 | ||
3c2f75b5 | 520 | test_done |