]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3206-range-diff.sh
t8013: minimum preparatory clean-up
[thirdparty/git.git] / t / t3206-range-diff.sh
CommitLineData
8884cf15
TR
1#!/bin/sh
2
3test_description='range-diff tests'
4
5. ./test-lib.sh
6
7# Note that because of the range-diff's heuristics, test_commit does more
8# harm than good. We need some real history.
9
10test_expect_success 'setup' '
3a6e48e9 11 git fast-import <"$TEST_DIRECTORY"/t3206/history.export &&
79f3950d 12 test_oid_cache <<-\EOF
b561edd2 13 # topic
14 t1 sha1:4de457d
15 t2 sha1:fccce22
16 t3 sha1:147e64e
17 t4 sha1:a63e992
18 t1 sha256:b89f8b9
19 t2 sha256:5f12aad
20 t3 sha256:ea8b273
21 t4 sha256:14b7336
22
23 # unmodified
24 u1 sha1:35b9b25
25 u2 sha1:de345ab
26 u3 sha1:9af6654
27 u4 sha1:2901f77
28 u1 sha256:e3731be
29 u2 sha256:14fadf8
30 u3 sha256:736c4bc
31 u4 sha256:673e77d
32
33 # reordered
34 r1 sha1:aca177a
35 r2 sha1:14ad629
36 r3 sha1:ee58208
37 r4 sha1:307b27a
38 r1 sha256:f59d3aa
39 r2 sha256:fb261a8
40 r3 sha256:cb2649b
41 r4 sha256:958577e
42
43 # removed (deleted)
44 d1 sha1:7657159
45 d2 sha1:43d84d3
46 d3 sha1:a740396
47 d1 sha256:e312513
48 d2 sha256:eb19258
49 d3 sha256:1ccb3c1
50
51 # added
52 a1 sha1:2716022
53 a2 sha1:b62accd
54 a3 sha1:df46cfa
55 a4 sha1:3e64548
56 a5 sha1:12b4063
57 a1 sha256:d724f4d
58 a2 sha256:1de7762
59 a3 sha256:e159431
60 a4 sha256:b3e483c
61 a5 sha256:90866a7
62
63 # rebased
64 b1 sha1:cc9c443
65 b2 sha1:c5d9641
66 b3 sha1:28cc2b6
67 b4 sha1:5628ab7
68 b5 sha1:a31b12e
69 b1 sha256:a1a8717
70 b2 sha256:20a5862
71 b3 sha256:587172a
72 b4 sha256:2721c5d
73 b5 sha256:7b57864
74
75 # changed
76 c1 sha1:a4b3333
77 c2 sha1:f51d370
78 c3 sha1:0559556
79 c4 sha1:d966c5c
80 c1 sha256:f8c2b9d
81 c2 sha256:3fb6318
82 c3 sha256:168ab68
83 c4 sha256:3526539
84
85 # changed-message
86 m1 sha1:f686024
87 m2 sha1:4ab067d
88 m3 sha1:b9cb956
89 m4 sha1:8add5f1
90 m1 sha256:31e6281
91 m2 sha256:a06bf1b
92 m3 sha256:82dc654
93 m4 sha256:48470c5
94
95 # renamed
96 n1 sha1:f258d75
97 n2 sha1:017b62d
98 n3 sha1:3ce7af6
99 n4 sha1:1e6226b
100 n1 sha256:ad52114
101 n2 sha256:3b54c8f
102 n3 sha256:3b0a644
103 n4 sha256:e461653
104
94db7e3e 105 # mode change
106 o1 sha1:4d39cb3
107 o2 sha1:26c107f
108 o3 sha1:4c1e0f5
109 o1 sha256:d0dd598
110 o2 sha256:c4a279e
111 o3 sha256:78459d7
112
b561edd2 113 # added and removed
114 s1 sha1:096b1ba
115 s2 sha1:d92e698
116 s3 sha1:9a1db4d
117 s4 sha1:fea3b5c
118 s1 sha256:a7f9134
119 s2 sha256:b4c2580
120 s3 sha256:1d62aa2
121 s4 sha256:48160e8
122
123 # Empty delimiter (included so lines match neatly)
124 __ sha1:-------
125 __ sha256:-------
126 EOF
8884cf15
TR
127'
128
129test_expect_success 'simple A..B A..C (unmodified)' '
130 git range-diff --no-color master..topic master..unmodified \
131 >actual &&
75c5aa07 132 cat >expect <<-EOF &&
b561edd2 133 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
134 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
135 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
136 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/
8884cf15 137 EOF
75c5aa07 138 test_cmp expect actual
8884cf15
TR
139'
140
141test_expect_success 'simple B...C (unmodified)' '
142 git range-diff --no-color topic...unmodified >actual &&
75c5aa07
DL
143 # same "expect" as above
144 test_cmp expect actual
8884cf15
TR
145'
146
147test_expect_success 'simple A B C (unmodified)' '
148 git range-diff --no-color master topic unmodified >actual &&
75c5aa07
DL
149 # same "expect" as above
150 test_cmp expect actual
8884cf15
TR
151'
152
153test_expect_success 'trivial reordering' '
154 git range-diff --no-color master topic reordered >actual &&
75c5aa07 155 cat >expect <<-EOF &&
b561edd2 156 1: $(test_oid t1) = 1: $(test_oid r1) s/5/A/
157 3: $(test_oid t3) = 2: $(test_oid r2) s/11/B/
158 4: $(test_oid t4) = 3: $(test_oid r3) s/12/B/
159 2: $(test_oid t2) = 4: $(test_oid r4) s/4/A/
8884cf15 160 EOF
75c5aa07 161 test_cmp expect actual
8884cf15
TR
162'
163
164test_expect_success 'removed a commit' '
165 git range-diff --no-color master topic removed >actual &&
75c5aa07 166 cat >expect <<-EOF &&
b561edd2 167 1: $(test_oid t1) = 1: $(test_oid d1) s/5/A/
168 2: $(test_oid t2) < -: $(test_oid __) s/4/A/
169 3: $(test_oid t3) = 2: $(test_oid d2) s/11/B/
170 4: $(test_oid t4) = 3: $(test_oid d3) s/12/B/
8884cf15 171 EOF
75c5aa07 172 test_cmp expect actual
8884cf15
TR
173'
174
175test_expect_success 'added a commit' '
176 git range-diff --no-color master topic added >actual &&
75c5aa07 177 cat >expect <<-EOF &&
b561edd2 178 1: $(test_oid t1) = 1: $(test_oid a1) s/5/A/
179 2: $(test_oid t2) = 2: $(test_oid a2) s/4/A/
180 -: $(test_oid __) > 3: $(test_oid a3) s/6/A/
181 3: $(test_oid t3) = 4: $(test_oid a4) s/11/B/
182 4: $(test_oid t4) = 5: $(test_oid a5) s/12/B/
8884cf15 183 EOF
75c5aa07 184 test_cmp expect actual
8884cf15
TR
185'
186
187test_expect_success 'new base, A B C' '
188 git range-diff --no-color master topic rebased >actual &&
75c5aa07 189 cat >expect <<-EOF &&
b561edd2 190 1: $(test_oid t1) = 1: $(test_oid b1) s/5/A/
191 2: $(test_oid t2) = 2: $(test_oid b2) s/4/A/
192 3: $(test_oid t3) = 3: $(test_oid b3) s/11/B/
193 4: $(test_oid t4) = 4: $(test_oid b4) s/12/B/
8884cf15 194 EOF
75c5aa07 195 test_cmp expect actual
8884cf15
TR
196'
197
198test_expect_success 'new base, B...C' '
199 # this syntax includes the commits from master!
200 git range-diff --no-color topic...rebased >actual &&
75c5aa07 201 cat >expect <<-EOF &&
b561edd2 202 -: $(test_oid __) > 1: $(test_oid b5) unrelated
203 1: $(test_oid t1) = 2: $(test_oid b1) s/5/A/
204 2: $(test_oid t2) = 3: $(test_oid b2) s/4/A/
205 3: $(test_oid t3) = 4: $(test_oid b3) s/11/B/
206 4: $(test_oid t4) = 5: $(test_oid b4) s/12/B/
8884cf15 207 EOF
75c5aa07 208 test_cmp expect actual
8884cf15
TR
209'
210
211test_expect_success 'changed commit' '
212 git range-diff --no-color topic...changed >actual &&
75c5aa07 213 cat >expect <<-EOF &&
b561edd2 214 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
215 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
216 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
499352c2 217 @@ file: A
8884cf15
TR
218 9
219 10
220 -11
221 -+B
222 ++BB
223 12
224 13
225 14
b561edd2 226 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
499352c2 227 @@ file
444e0969 228 @@ file: A
8884cf15
TR
229 9
230 10
231 - B
232 + BB
233 -12
234 +B
235 13
236 EOF
75c5aa07 237 test_cmp expect actual
8884cf15
TR
238'
239
4624185a
ÆAB
240test_expect_success 'changed commit with --no-patch diff option' '
241 git range-diff --no-color --no-patch topic...changed >actual &&
75c5aa07 242 cat >expect <<-EOF &&
b561edd2 243 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
244 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
245 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
246 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
4624185a 247 EOF
75c5aa07 248 test_cmp expect actual
4624185a
ÆAB
249'
250
251test_expect_success 'changed commit with --stat diff option' '
4624185a 252 git range-diff --no-color --stat topic...changed >actual &&
75c5aa07 253 cat >expect <<-EOF &&
b561edd2 254 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
4624185a
ÆAB
255 a => b | 0
256 1 file changed, 0 insertions(+), 0 deletions(-)
b561edd2 257 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
4624185a
ÆAB
258 a => b | 0
259 1 file changed, 0 insertions(+), 0 deletions(-)
b561edd2 260 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
4624185a
ÆAB
261 a => b | 0
262 1 file changed, 0 insertions(+), 0 deletions(-)
b561edd2 263 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
4624185a
ÆAB
264 a => b | 0
265 1 file changed, 0 insertions(+), 0 deletions(-)
4624185a 266 EOF
75c5aa07 267 test_cmp expect actual
4624185a
ÆAB
268'
269
0e573e8f
LDM
270test_expect_success 'changed commit with sm config' '
271 git range-diff --no-color --submodule=log topic...changed >actual &&
75c5aa07 272 cat >expect <<-EOF &&
b561edd2 273 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
274 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
275 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
499352c2 276 @@ file: A
0e573e8f
LDM
277 9
278 10
279 -11
280 -+B
281 ++BB
282 12
283 13
284 14
b561edd2 285 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
499352c2 286 @@ file
444e0969 287 @@ file: A
0e573e8f
LDM
288 9
289 10
290 - B
291 + BB
292 -12
293 +B
294 13
295 EOF
75c5aa07 296 test_cmp expect actual
0e573e8f
LDM
297'
298
b66885a3
TG
299test_expect_success 'renamed file' '
300 git range-diff --no-color --submodule=log topic...renamed-file >actual &&
75c5aa07 301 sed s/Z/\ /g >expect <<-EOF &&
b561edd2 302 1: $(test_oid t1) = 1: $(test_oid n1) s/5/A/
303 2: $(test_oid t2) ! 2: $(test_oid n2) s/4/A/
499352c2 304 @@ Metadata
b66885a3
TG
305 ZAuthor: Thomas Rast <trast@inf.ethz.ch>
306 Z
499352c2 307 Z ## Commit message ##
b66885a3
TG
308 - s/4/A/
309 + s/4/A/ + rename file
310 Z
311 - ## file ##
312 + ## file => renamed-file ##
313 Z@@
314 Z 1
315 Z 2
b561edd2 316 3: $(test_oid t3) ! 3: $(test_oid n3) s/11/B/
499352c2
TG
317 @@ Metadata
318 Z ## Commit message ##
b66885a3
TG
319 Z s/11/B/
320 Z
321 - ## file ##
444e0969 322 -@@ file: A
b66885a3 323 + ## renamed-file ##
444e0969 324 +@@ renamed-file: A
b66885a3
TG
325 Z 8
326 Z 9
444e0969 327 Z 10
b561edd2 328 4: $(test_oid t4) ! 4: $(test_oid n4) s/12/B/
499352c2
TG
329 @@ Metadata
330 Z ## Commit message ##
b66885a3
TG
331 Z s/12/B/
332 Z
333 - ## file ##
444e0969 334 -@@ file: A
b66885a3 335 + ## renamed-file ##
444e0969 336 +@@ renamed-file: A
b66885a3
TG
337 Z 9
338 Z 10
444e0969 339 Z B
b66885a3 340 EOF
75c5aa07 341 test_cmp expect actual
b66885a3
TG
342'
343
2b6a9b13
TG
344test_expect_success 'file with mode only change' '
345 git range-diff --no-color --submodule=log topic...mode-only-change >actual &&
75c5aa07 346 sed s/Z/\ /g >expect <<-EOF &&
94db7e3e 347 1: $(test_oid t2) ! 1: $(test_oid o1) s/4/A/
2b6a9b13
TG
348 @@ Metadata
349 ZAuthor: Thomas Rast <trast@inf.ethz.ch>
350 Z
351 Z ## Commit message ##
352 - s/4/A/
353 + s/4/A/ + add other-file
354 Z
355 Z ## file ##
356 Z@@
357 @@ file
358 Z A
359 Z 6
360 Z 7
361 +
362 + ## other-file (new) ##
94db7e3e 363 2: $(test_oid t3) ! 2: $(test_oid o2) s/11/B/
2b6a9b13
TG
364 @@ Metadata
365 ZAuthor: Thomas Rast <trast@inf.ethz.ch>
366 Z
367 Z ## Commit message ##
368 - s/11/B/
369 + s/11/B/ + mode change other-file
370 Z
371 Z ## file ##
372 Z@@ file: A
373 @@ file: A
374 Z 12
375 Z 13
376 Z 14
377 +
378 + ## other-file (mode change 100644 => 100755) ##
94db7e3e 379 3: $(test_oid t4) = 3: $(test_oid o3) s/12/B/
2b6a9b13 380 EOF
75c5aa07 381 test_cmp expect actual
2b6a9b13
TG
382'
383
b66885a3
TG
384test_expect_success 'file added and later removed' '
385 git range-diff --no-color --submodule=log topic...added-removed >actual &&
75c5aa07 386 sed s/Z/\ /g >expect <<-EOF &&
b561edd2 387 1: $(test_oid t1) = 1: $(test_oid s1) s/5/A/
388 2: $(test_oid t2) ! 2: $(test_oid s2) s/4/A/
499352c2 389 @@ Metadata
b66885a3
TG
390 ZAuthor: Thomas Rast <trast@inf.ethz.ch>
391 Z
499352c2 392 Z ## Commit message ##
b66885a3
TG
393 - s/4/A/
394 + s/4/A/ + new-file
395 Z
396 Z ## file ##
397 Z@@
499352c2 398 @@ file
b66885a3
TG
399 Z A
400 Z 6
401 Z 7
402 +
403 + ## new-file (new) ##
b561edd2 404 3: $(test_oid t3) ! 3: $(test_oid s3) s/11/B/
499352c2 405 @@ Metadata
b66885a3
TG
406 ZAuthor: Thomas Rast <trast@inf.ethz.ch>
407 Z
499352c2 408 Z ## Commit message ##
b66885a3
TG
409 - s/11/B/
410 + s/11/B/ + remove file
411 Z
412 Z ## file ##
444e0969 413 Z@@ file: A
499352c2 414 @@ file: A
b66885a3
TG
415 Z 12
416 Z 13
417 Z 14
418 +
419 + ## new-file (deleted) ##
b561edd2 420 4: $(test_oid t4) = 4: $(test_oid s4) s/12/B/
b66885a3 421 EOF
75c5aa07 422 test_cmp expect actual
b66885a3
TG
423'
424
51bbcda1
JH
425test_expect_success 'no commits on one side' '
426 git commit --amend -m "new message" &&
427 git range-diff master HEAD@{1} HEAD
428'
429
8884cf15
TR
430test_expect_success 'changed message' '
431 git range-diff --no-color topic...changed-message >actual &&
75c5aa07 432 sed s/Z/\ /g >expect <<-EOF &&
b561edd2 433 1: $(test_oid t1) = 1: $(test_oid m1) s/5/A/
434 2: $(test_oid t2) ! 2: $(test_oid m2) s/4/A/
499352c2
TG
435 @@ Metadata
436 Z ## Commit message ##
8884cf15
TR
437 Z s/4/A/
438 Z
439 + Also a silly comment here!
440 +
b66885a3
TG
441 Z ## file ##
442 Z@@
443 Z 1
b561edd2 444 3: $(test_oid t3) = 3: $(test_oid m3) s/11/B/
445 4: $(test_oid t4) = 4: $(test_oid m4) s/12/B/
8884cf15 446 EOF
75c5aa07 447 test_cmp expect actual
8884cf15
TR
448'
449
c5e64caa 450test_expect_success 'dual-coloring' '
b561edd2 451 sed -e "s|^:||" >expect <<-EOF &&
452 :<YELLOW>1: $(test_oid c1) = 1: $(test_oid m1) s/5/A/<RESET>
453 :<RED>2: $(test_oid c2) <RESET><YELLOW>!<RESET><GREEN> 2: $(test_oid m2)<RESET><YELLOW> s/4/A/<RESET>
499352c2
TG
454 : <REVERSE><CYAN>@@<RESET> <RESET>Metadata<RESET>
455 : ## Commit message ##<RESET>
c5e64caa
SB
456 : s/4/A/<RESET>
457 : <RESET>
458 : <REVERSE><GREEN>+<RESET><BOLD> Also a silly comment here!<RESET>
29ef759d 459 : <REVERSE><GREEN>+<RESET>
b66885a3
TG
460 : ## file ##<RESET>
461 : <CYAN> @@<RESET>
462 : 1<RESET>
b561edd2 463 :<RED>3: $(test_oid c3) <RESET><YELLOW>!<RESET><GREEN> 3: $(test_oid m3)<RESET><YELLOW> s/11/B/<RESET>
499352c2 464 : <REVERSE><CYAN>@@<RESET> <RESET>file: A<RESET>
c5e64caa
SB
465 : 9<RESET>
466 : 10<RESET>
467 : <RED> -11<RESET>
468 : <REVERSE><RED>-<RESET><FAINT;GREEN>+BB<RESET>
469 : <REVERSE><GREEN>+<RESET><BOLD;GREEN>+B<RESET>
470 : 12<RESET>
471 : 13<RESET>
472 : 14<RESET>
b561edd2 473 :<RED>4: $(test_oid c4) <RESET><YELLOW>!<RESET><GREEN> 4: $(test_oid m4)<RESET><YELLOW> s/12/B/<RESET>
499352c2 474 : <REVERSE><CYAN>@@<RESET> <RESET>file<RESET>
444e0969 475 : <CYAN> @@ file: A<RESET>
c5e64caa
SB
476 : 9<RESET>
477 : 10<RESET>
478 : <REVERSE><RED>-<RESET><FAINT> BB<RESET>
479 : <REVERSE><GREEN>+<RESET><BOLD> B<RESET>
480 : <RED> -12<RESET>
481 : <GREEN> +B<RESET>
482 : 13<RESET>
483 EOF
484 git range-diff changed...changed-message --color --dual-color >actual.raw &&
485 test_decode_color >actual <actual.raw &&
486 test_cmp expect actual
487'
488
2e6fd71a 489for prev in topic master..topic
31e2617a
ES
490do
491 test_expect_success "format-patch --range-diff=$prev" '
ac0edf1f 492 git format-patch --cover-letter --range-diff=$prev \
31e2617a 493 master..unmodified >actual &&
ac0edf1f
494 test_when_finished "rm 000?-*" &&
495 test_line_count = 5 actual &&
496 test_i18ngrep "^Range-diff:$" 0000-* &&
497 grep "= 1: .* s/5/A" 0000-* &&
498 grep "= 2: .* s/4/A" 0000-* &&
499 grep "= 3: .* s/11/B" 0000-* &&
500 grep "= 4: .* s/12/B" 0000-*
31e2617a
ES
501 '
502done
503
cdc067c3 504test_expect_success 'format-patch --range-diff as commentary' '
ac0edf1f
505 git format-patch --range-diff=HEAD~1 HEAD~1 >actual &&
506 test_when_finished "rm 0001-*" &&
507 test_line_count = 1 actual &&
508 test_i18ngrep "^Range-diff:$" 0001-* &&
509 grep "> 1: .* new message" 0001-*
cdc067c3
DS
510'
511
937b76ed
JS
512test_expect_success 'range-diff overrides diff.noprefix internally' '
513 git -c diff.noprefix=true range-diff HEAD^...
514'
515
8cf51561
VD
516test_expect_success 'basic with modified format.pretty with suffix' '
517 git -c format.pretty="format:commit %H%d%n" range-diff \
518 master..topic master..unmodified
519'
520
521test_expect_success 'basic with modified format.pretty without "commit "' '
522 git -c format.pretty="format:%H%n" range-diff \
523 master..topic master..unmodified
524'
525
3bdbdfb7
DL
526test_expect_success 'range-diff compares notes by default' '
527 git notes add -m "topic note" topic &&
528 git notes add -m "unmodified note" unmodified &&
529 test_when_finished git notes remove topic unmodified &&
530 git range-diff --no-color master..topic master..unmodified \
531 >actual &&
532 sed s/Z/\ /g >expect <<-EOF &&
533 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
534 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
535 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
536 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
9f726e1b 537 @@ Commit message
3bdbdfb7 538 Z
9f726e1b
DL
539 Z
540 Z ## Notes ##
3bdbdfb7
DL
541 - topic note
542 + unmodified note
543 Z
544 Z ## file ##
545 Z@@ file: A
546 EOF
547 test_cmp expect actual
548'
549
bd361918
DL
550test_expect_success 'range-diff with --no-notes' '
551 git notes add -m "topic note" topic &&
552 git notes add -m "unmodified note" unmodified &&
553 test_when_finished git notes remove topic unmodified &&
554 git range-diff --no-color --no-notes master..topic master..unmodified \
555 >actual &&
556 cat >expect <<-EOF &&
557 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
558 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
559 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
560 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/
561 EOF
562 test_cmp expect actual
563'
564
565test_expect_success 'range-diff with multiple --notes' '
566 git notes --ref=note1 add -m "topic note1" topic &&
567 git notes --ref=note1 add -m "unmodified note1" unmodified &&
568 test_when_finished git notes --ref=note1 remove topic unmodified &&
569 git notes --ref=note2 add -m "topic note2" topic &&
570 git notes --ref=note2 add -m "unmodified note2" unmodified &&
571 test_when_finished git notes --ref=note2 remove topic unmodified &&
572 git range-diff --no-color --notes=note1 --notes=note2 master..topic master..unmodified \
573 >actual &&
574 sed s/Z/\ /g >expect <<-EOF &&
575 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
576 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
577 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
578 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
579 @@ Commit message
580 Z
581 Z
582 Z ## Notes (note1) ##
583 - topic note1
584 + unmodified note1
585 Z
586 Z
587 Z ## Notes (note2) ##
588 - topic note2
589 + unmodified note2
590 Z
591 Z ## file ##
592 Z@@ file: A
593 EOF
594 test_cmp expect actual
595'
596
5b583e6a 597test_expect_success 'format-patch --range-diff does not compare notes by default' '
3bdbdfb7
DL
598 git notes add -m "topic note" topic &&
599 git notes add -m "unmodified note" unmodified &&
600 test_when_finished git notes remove topic unmodified &&
601 git format-patch --cover-letter --range-diff=$prev \
602 master..unmodified >actual &&
603 test_when_finished "rm 000?-*" &&
604 test_line_count = 5 actual &&
605 test_i18ngrep "^Range-diff:$" 0000-* &&
606 grep "= 1: .* s/5/A" 0000-* &&
607 grep "= 2: .* s/4/A" 0000-* &&
608 grep "= 3: .* s/11/B" 0000-* &&
5b583e6a
DL
609 grep "= 4: .* s/12/B" 0000-* &&
610 ! grep "Notes" 0000-* &&
611 ! grep "note" 0000-*
612'
613
614test_expect_success 'format-patch --range-diff with --no-notes' '
615 git notes add -m "topic note" topic &&
616 git notes add -m "unmodified note" unmodified &&
617 test_when_finished git notes remove topic unmodified &&
618 git format-patch --no-notes --cover-letter --range-diff=$prev \
619 master..unmodified >actual &&
620 test_when_finished "rm 000?-*" &&
621 test_line_count = 5 actual &&
622 test_i18ngrep "^Range-diff:$" 0000-* &&
623 grep "= 1: .* s/5/A" 0000-* &&
624 grep "= 2: .* s/4/A" 0000-* &&
625 grep "= 3: .* s/11/B" 0000-* &&
626 grep "= 4: .* s/12/B" 0000-* &&
627 ! grep "Notes" 0000-* &&
628 ! grep "note" 0000-*
629'
630
631test_expect_success 'format-patch --range-diff with --notes' '
632 git notes add -m "topic note" topic &&
633 git notes add -m "unmodified note" unmodified &&
634 test_when_finished git notes remove topic unmodified &&
635 git format-patch --notes --cover-letter --range-diff=$prev \
636 master..unmodified >actual &&
637 test_when_finished "rm 000?-*" &&
638 test_line_count = 5 actual &&
639 test_i18ngrep "^Range-diff:$" 0000-* &&
640 grep "= 1: .* s/5/A" 0000-* &&
641 grep "= 2: .* s/4/A" 0000-* &&
642 grep "= 3: .* s/11/B" 0000-* &&
3bdbdfb7
DL
643 grep "! 4: .* s/12/B" 0000-* &&
644 sed s/Z/\ /g >expect <<-EOF &&
9f726e1b 645 @@ Commit message
3bdbdfb7 646 Z
9f726e1b
DL
647 Z
648 Z ## Notes ##
3bdbdfb7
DL
649 - topic note
650 + unmodified note
651 Z
652 Z ## file ##
653 Z@@ file: A
654 EOF
9f726e1b 655 sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
3bdbdfb7
DL
656 test_cmp expect actual
657'
658
828765df 659test_expect_success 'format-patch --range-diff with format.notes config' '
5b583e6a
DL
660 git notes add -m "topic note" topic &&
661 git notes add -m "unmodified note" unmodified &&
662 test_when_finished git notes remove topic unmodified &&
663 test_config format.notes true &&
664 git format-patch --cover-letter --range-diff=$prev \
665 master..unmodified >actual &&
666 test_when_finished "rm 000?-*" &&
667 test_line_count = 5 actual &&
668 test_i18ngrep "^Range-diff:$" 0000-* &&
669 grep "= 1: .* s/5/A" 0000-* &&
670 grep "= 2: .* s/4/A" 0000-* &&
671 grep "= 3: .* s/11/B" 0000-* &&
672 grep "! 4: .* s/12/B" 0000-* &&
673 sed s/Z/\ /g >expect <<-EOF &&
674 @@ Commit message
675 Z
676 Z
677 Z ## Notes ##
678 - topic note
679 + unmodified note
680 Z
681 Z ## file ##
682 Z@@ file: A
683 EOF
684 sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
685 test_cmp expect actual
686'
687
688test_expect_success 'format-patch --range-diff with multiple notes' '
689 git notes --ref=note1 add -m "topic note1" topic &&
690 git notes --ref=note1 add -m "unmodified note1" unmodified &&
691 test_when_finished git notes --ref=note1 remove topic unmodified &&
692 git notes --ref=note2 add -m "topic note2" topic &&
693 git notes --ref=note2 add -m "unmodified note2" unmodified &&
694 test_when_finished git notes --ref=note2 remove topic unmodified &&
695 git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \
696 master..unmodified >actual &&
697 test_when_finished "rm 000?-*" &&
698 test_line_count = 5 actual &&
699 test_i18ngrep "^Range-diff:$" 0000-* &&
700 grep "= 1: .* s/5/A" 0000-* &&
701 grep "= 2: .* s/4/A" 0000-* &&
702 grep "= 3: .* s/11/B" 0000-* &&
703 grep "! 4: .* s/12/B" 0000-* &&
704 sed s/Z/\ /g >expect <<-EOF &&
705 @@ Commit message
706 Z
707 Z
708 Z ## Notes (note1) ##
709 - topic note1
710 + unmodified note1
711 Z
712 Z
713 Z ## Notes (note2) ##
714 - topic note2
715 + unmodified note2
716 Z
717 Z ## file ##
718 Z@@ file: A
719 EOF
720 sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
721 test_cmp expect actual
722'
723
8884cf15 724test_done