format-patch: teach format.notes config option
[git/git.git] / t / t4014-format-patch.sh
CommitLineData
ece3c67f
JH
1#!/bin/sh
2#
3# Copyright (c) 2006 Junio C Hamano
4#
5
9800a754 6test_description='various format-patch tests'
ece3c67f
JH
7
8. ./test-lib.sh
38a94bb6 9. "$TEST_DIRECTORY"/lib-terminal.sh
ece3c67f
JH
10
11test_expect_success setup '
12
13 for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
cd894ee9
JH
14 cat file >elif &&
15 git add file elif &&
6426f2d2 16 test_tick &&
ece3c67f
JH
17 git commit -m Initial &&
18 git checkout -b side &&
19
20 for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file &&
1f553918 21 test_chmod +x elif &&
6426f2d2 22 test_tick &&
816366e2 23 git commit -m "Side changes #1" &&
ece3c67f
JH
24
25 for i in D E F; do echo "$i"; done >>file &&
26 git update-index file &&
6426f2d2 27 test_tick &&
816366e2 28 git commit -m "Side changes #2" &&
982b64e4 29 git tag C2 &&
ece3c67f
JH
30
31 for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file &&
32 git update-index file &&
6426f2d2 33 test_tick &&
816366e2 34 git commit -m "Side changes #3 with \\n backslash-n in it." &&
ece3c67f
JH
35
36 git checkout master &&
982b64e4 37 git diff-tree -p C2 | git apply --index &&
6426f2d2 38 test_tick &&
982b64e4 39 git commit -m "Master accepts moral equivalent of #2"
ece3c67f
JH
40
41'
42
43test_expect_success "format-patch --ignore-if-in-upstream" '
44
45 git format-patch --stdout master..side >patch0 &&
54835fc5 46 cnt=$(grep "^From " patch0 | wc -l) &&
8780bd8f 47 test $cnt = 3
ece3c67f
JH
48
49'
50
51test_expect_success "format-patch --ignore-if-in-upstream" '
52
53 git format-patch --stdout \
54 --ignore-if-in-upstream master..side >patch1 &&
54835fc5 55 cnt=$(grep "^From " patch1 | wc -l) &&
8780bd8f 56 test $cnt = 2
ece3c67f
JH
57
58'
59
9b7a61d7
JH
60test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
61 git tag -a v1 -m tag side &&
62 git tag -a v2 -m tag master &&
63 git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&
64 cnt=$(grep "^From " patch1 | wc -l) &&
65 test $cnt = 2
66'
67
2c642ed8
RR
68test_expect_success "format-patch doesn't consider merge commits" '
69
70 git checkout -b slave master &&
71 echo "Another line" >>file &&
72 test_tick &&
73 git commit -am "Slave change #1" &&
74 echo "Yet another line" >>file &&
75 test_tick &&
76 git commit -am "Slave change #2" &&
77 git checkout -b merger master &&
78 test_tick &&
79 git merge --no-ff slave &&
54835fc5 80 cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&
2c642ed8
RR
81 test $cnt = 3
82'
83
ece3c67f
JH
84test_expect_success "format-patch result applies" '
85
86 git checkout -b rebuild-0 master &&
87 git am -3 patch0 &&
54835fc5 88 cnt=$(git rev-list master.. | wc -l) &&
8780bd8f 89 test $cnt = 2
ece3c67f
JH
90'
91
92test_expect_success "format-patch --ignore-if-in-upstream result applies" '
93
94 git checkout -b rebuild-1 master &&
95 git am -3 patch1 &&
54835fc5 96 cnt=$(git rev-list master.. | wc -l) &&
8780bd8f 97 test $cnt = 2
ece3c67f
JH
98'
99
816366e2
JH
100test_expect_success 'commit did not screw up the log message' '
101
102 git cat-file commit side | grep "^Side .* with .* backslash-n"
103
104'
105
106test_expect_success 'format-patch did not screw up the log message' '
107
108 grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
109 grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
110
111'
112
113test_expect_success 'replay did not screw up the log message' '
114
115 git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
116
117'
118
a8d8173e
DB
119test_expect_success 'extra headers' '
120
25dc8dad 121 git config format.headers "To: R E Cipient <rcipient@example.com>
a8d8173e 122" &&
25dc8dad 123 git config --add format.headers "Cc: S E Cipient <scipient@example.com>
a8d8173e
DB
124" &&
125 git format-patch --stdout master..side > patch2 &&
9524cf29 126 sed -e "/^\$/q" patch2 > hdrs2 &&
25dc8dad
JS
127 grep "^To: R E Cipient <rcipient@example.com>\$" hdrs2 &&
128 grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs2
3b2eb186 129
a8d8173e
DB
130'
131
7d22708b 132test_expect_success 'extra headers without newlines' '
a8d8173e 133
25dc8dad
JS
134 git config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" &&
135 git config --add format.headers "Cc: S E Cipient <scipient@example.com>" &&
a8d8173e 136 git format-patch --stdout master..side >patch3 &&
9524cf29 137 sed -e "/^\$/q" patch3 > hdrs3 &&
25dc8dad
JS
138 grep "^To: R E Cipient <rcipient@example.com>\$" hdrs3 &&
139 grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs3
3b2eb186 140
a8d8173e
DB
141'
142
3ee79d9f 143test_expect_success 'extra headers with multiple To:s' '
a8d8173e 144
25dc8dad
JS
145 git config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" &&
146 git config --add format.headers "To: S E Cipient <scipient@example.com>" &&
a8d8173e 147 git format-patch --stdout master..side > patch4 &&
9524cf29 148 sed -e "/^\$/q" patch4 > hdrs4 &&
25dc8dad
JS
149 grep "^To: R E Cipient <rcipient@example.com>,\$" hdrs4 &&
150 grep "^ *S E Cipient <scipient@example.com>\$" hdrs4
a8d8173e
DB
151'
152
25dc8dad 153test_expect_success 'additional command line cc (ascii)' '
736cc67d 154
25dc8dad
JS
155 git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
156 git format-patch --cc="S E Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
157 grep "^Cc: R E Cipient <rcipient@example.com>,\$" patch5 &&
158 grep "^ *S E Cipient <scipient@example.com>\$" patch5
159'
160
161test_expect_failure 'additional command line cc (rfc822)' '
162
163 git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
9524cf29 164 git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
25dc8dad 165 grep "^Cc: R E Cipient <rcipient@example.com>,\$" patch5 &&
27f6342f 166 grep "^ *\"S. E. Cipient\" <scipient@example.com>\$" patch5
736cc67d
DB
167'
168
d7d9c2d0
MH
169test_expect_success 'command line headers' '
170
171 git config --unset-all format.headers &&
25dc8dad
JS
172 git format-patch --add-header="Cc: R E Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
173 grep "^Cc: R E Cipient <rcipient@example.com>\$" patch6
d7d9c2d0
MH
174'
175
176test_expect_success 'configuration headers and command line headers' '
177
25dc8dad
JS
178 git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
179 git format-patch --add-header="Cc: S E Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
180 grep "^Cc: R E Cipient <rcipient@example.com>,\$" patch7 &&
181 grep "^ *S E Cipient <scipient@example.com>\$" patch7
d7d9c2d0
MH
182'
183
25dc8dad 184test_expect_success 'command line To: header (ascii)' '
ae6c098f
SD
185
186 git config --unset-all format.headers &&
25dc8dad
JS
187 git format-patch --to="R E Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
188 grep "^To: R E Cipient <rcipient@example.com>\$" patch8
189'
190
191test_expect_failure 'command line To: header (rfc822)' '
192
ae6c098f 193 git format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
27f6342f 194 grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" patch8
25dc8dad
JS
195'
196
197test_expect_failure 'command line To: header (rfc2047)' '
198
199 git format-patch --to="R Ä Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
200 grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" patch8
ae6c098f
SD
201'
202
25dc8dad
JS
203test_expect_success 'configuration To: header (ascii)' '
204
205 git config format.to "R E Cipient <rcipient@example.com>" &&
206 git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
207 grep "^To: R E Cipient <rcipient@example.com>\$" patch9
208'
209
210test_expect_failure 'configuration To: header (rfc822)' '
ae6c098f
SD
211
212 git config format.to "R. E. Cipient <rcipient@example.com>" &&
213 git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
27f6342f 214 grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" patch9
25dc8dad
JS
215'
216
217test_expect_failure 'configuration To: header (rfc2047)' '
218
219 git config format.to "R Ä Cipient <rcipient@example.com>" &&
220 git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
221 grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" patch9
ae6c098f
SD
222'
223
cc663d14
TR
224# check_patch <patch>: Verify that <patch> looks like a half-sane
225# patch email to avoid a false positive with !grep
226check_patch () {
227 grep -e "^From:" "$1" &&
228 grep -e "^Date:" "$1" &&
229 grep -e "^Subject:" "$1"
230}
231
6bc6b6c0
JT
232test_expect_success 'format.from=false' '
233
234 git -c format.from=false format-patch --stdout master..side |
235 sed -e "/^\$/q" >patch &&
236 check_patch patch &&
237 ! grep "^From: C O Mitter <committer@example.com>\$" patch
238'
239
240test_expect_success 'format.from=true' '
241
242 git -c format.from=true format-patch --stdout master..side |
243 sed -e "/^\$/q" >patch &&
244 check_patch patch &&
245 grep "^From: C O Mitter <committer@example.com>\$" patch
246'
247
248test_expect_success 'format.from with address' '
249
250 git -c format.from="F R Om <from@example.com>" format-patch --stdout master..side |
251 sed -e "/^\$/q" >patch &&
252 check_patch patch &&
253 grep "^From: F R Om <from@example.com>\$" patch
254'
255
256test_expect_success '--no-from overrides format.from' '
257
258 git -c format.from="F R Om <from@example.com>" format-patch --no-from --stdout master..side |
259 sed -e "/^\$/q" >patch &&
260 check_patch patch &&
261 ! grep "^From: F R Om <from@example.com>\$" patch
262'
263
264test_expect_success '--from overrides format.from' '
265
266 git -c format.from="F R Om <from@example.com>" format-patch --from --stdout master..side |
267 sed -e "/^\$/q" >patch &&
268 check_patch patch &&
269 ! grep "^From: F R Om <from@example.com>\$" patch
270'
271
c4260034
SB
272test_expect_success '--no-to overrides config.to' '
273
274 git config --replace-all format.to \
25dc8dad 275 "R E Cipient <rcipient@example.com>" &&
c4260034
SB
276 git format-patch --no-to --stdout master..side |
277 sed -e "/^\$/q" >patch10 &&
cc663d14 278 check_patch patch10 &&
25dc8dad 279 ! grep "^To: R E Cipient <rcipient@example.com>\$" patch10
c4260034
SB
280'
281
282test_expect_success '--no-to and --to replaces config.to' '
283
284 git config --replace-all format.to \
285 "Someone <someone@out.there>" &&
286 git format-patch --no-to --to="Someone Else <else@out.there>" \
287 --stdout master..side |
288 sed -e "/^\$/q" >patch11 &&
cc663d14 289 check_patch patch11 &&
c4260034
SB
290 ! grep "^To: Someone <someone@out.there>\$" patch11 &&
291 grep "^To: Someone Else <else@out.there>\$" patch11
292'
293
294test_expect_success '--no-cc overrides config.cc' '
295
296 git config --replace-all format.cc \
25dc8dad 297 "C E Cipient <rcipient@example.com>" &&
c4260034
SB
298 git format-patch --no-cc --stdout master..side |
299 sed -e "/^\$/q" >patch12 &&
cc663d14 300 check_patch patch12 &&
25dc8dad 301 ! grep "^Cc: C E Cipient <rcipient@example.com>\$" patch12
c4260034
SB
302'
303
688f4f2f 304test_expect_success '--no-add-header overrides config.headers' '
c4260034
SB
305
306 git config --replace-all format.headers \
25dc8dad 307 "Header1: B E Cipient <rcipient@example.com>" &&
688f4f2f 308 git format-patch --no-add-header --stdout master..side |
c4260034 309 sed -e "/^\$/q" >patch13 &&
cc663d14 310 check_patch patch13 &&
25dc8dad 311 ! grep "^Header1: B E Cipient <rcipient@example.com>\$" patch13
c4260034
SB
312'
313
7d812145
DB
314test_expect_success 'multiple files' '
315
316 rm -rf patches/ &&
317 git checkout side &&
318 git format-patch -o patches/ master &&
319 ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch
320'
321
4aad08e0
JH
322test_expect_success 'reroll count' '
323 rm -fr patches &&
324 git format-patch -o patches --cover-letter --reroll-count 4 master..side >list &&
325 ! grep -v "^patches/v4-000[0-3]-" list &&
326 sed -n -e "/^Subject: /p" $(cat list) >subjects &&
327 ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
328'
329
7952ea66
JH
330test_expect_success 'reroll count (-v)' '
331 rm -fr patches &&
332 git format-patch -o patches --cover-letter -v4 master..side >list &&
333 ! grep -v "^patches/v4-000[0-3]-" list &&
334 sed -n -e "/^Subject: /p" $(cat list) >subjects &&
335 ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects
336'
337
484cf6c3
TR
338check_threading () {
339 expect="$1" &&
340 shift &&
341 (git format-patch --stdout "$@"; echo $? > status.out) |
342 # Prints everything between the Message-ID and In-Reply-To,
343 # and replaces all Message-ID-lookalikes by a sequence number
94221d22 344 perl -ne '
484cf6c3
TR
345 if (/^(message-id|references|in-reply-to)/i) {
346 $printing = 1;
347 } elsif (/^\S/) {
348 $printing = 0;
349 }
350 if ($printing) {
351 $h{$1}=$i++ if (/<([^>]+)>/ and !exists $h{$1});
352 for $k (keys %h) {s/$k/$h{$k}/};
353 print;
354 }
355 print "---\n" if /^From /i;
356 ' > actual &&
357 test 0 = "$(cat status.out)" &&
358 test_cmp "$expect" actual
359}
360
361cat >> expect.no-threading <<EOF
362---
363---
364---
365EOF
366
367test_expect_success 'no threading' '
7d812145 368 git checkout side &&
484cf6c3 369 check_threading expect.no-threading master
7d812145
DB
370'
371
484cf6c3
TR
372cat > expect.thread <<EOF
373---
374Message-Id: <0>
375---
376Message-Id: <1>
377In-Reply-To: <0>
378References: <0>
379---
380Message-Id: <2>
381In-Reply-To: <0>
382References: <0>
383EOF
7d812145 384
484cf6c3
TR
385test_expect_success 'thread' '
386 check_threading expect.thread --thread master
7d812145
DB
387'
388
484cf6c3
TR
389cat > expect.in-reply-to <<EOF
390---
391Message-Id: <0>
392In-Reply-To: <1>
393References: <1>
394---
395Message-Id: <2>
396In-Reply-To: <1>
397References: <1>
398---
399Message-Id: <3>
400In-Reply-To: <1>
401References: <1>
402EOF
a5a27c79 403
484cf6c3
TR
404test_expect_success 'thread in-reply-to' '
405 check_threading expect.in-reply-to --in-reply-to="<test.message>" \
406 --thread master
a5a27c79
DB
407'
408
484cf6c3
TR
409cat > expect.cover-letter <<EOF
410---
411Message-Id: <0>
412---
413Message-Id: <1>
414In-Reply-To: <0>
415References: <0>
416---
417Message-Id: <2>
418In-Reply-To: <0>
419References: <0>
420---
421Message-Id: <3>
422In-Reply-To: <0>
423References: <0>
424EOF
a5a27c79 425
484cf6c3
TR
426test_expect_success 'thread cover-letter' '
427 check_threading expect.cover-letter --cover-letter --thread master
428'
429
430cat > expect.cl-irt <<EOF
431---
432Message-Id: <0>
433In-Reply-To: <1>
434References: <1>
435---
436Message-Id: <2>
2175c10d 437In-Reply-To: <0>
484cf6c3 438References: <1>
2175c10d 439 <0>
484cf6c3
TR
440---
441Message-Id: <3>
2175c10d 442In-Reply-To: <0>
484cf6c3 443References: <1>
2175c10d 444 <0>
484cf6c3
TR
445---
446Message-Id: <4>
2175c10d 447In-Reply-To: <0>
484cf6c3 448References: <1>
2175c10d 449 <0>
484cf6c3
TR
450EOF
451
452test_expect_success 'thread cover-letter in-reply-to' '
453 check_threading expect.cl-irt --cover-letter \
454 --in-reply-to="<test.message>" --thread master
a5a27c79
DB
455'
456
30984ed2
TR
457test_expect_success 'thread explicit shallow' '
458 check_threading expect.cl-irt --cover-letter \
459 --in-reply-to="<test.message>" --thread=shallow master
460'
461
462cat > expect.deep <<EOF
463---
464Message-Id: <0>
465---
466Message-Id: <1>
467In-Reply-To: <0>
468References: <0>
469---
470Message-Id: <2>
471In-Reply-To: <1>
472References: <0>
473 <1>
474EOF
475
476test_expect_success 'thread deep' '
477 check_threading expect.deep --thread=deep master
478'
479
480cat > expect.deep-irt <<EOF
481---
482Message-Id: <0>
483In-Reply-To: <1>
484References: <1>
485---
486Message-Id: <2>
487In-Reply-To: <0>
488References: <1>
489 <0>
490---
491Message-Id: <3>
492In-Reply-To: <2>
493References: <1>
494 <0>
495 <2>
496EOF
497
498test_expect_success 'thread deep in-reply-to' '
499 check_threading expect.deep-irt --thread=deep \
500 --in-reply-to="<test.message>" master
501'
502
503cat > expect.deep-cl <<EOF
504---
505Message-Id: <0>
506---
507Message-Id: <1>
508In-Reply-To: <0>
509References: <0>
510---
511Message-Id: <2>
512In-Reply-To: <1>
513References: <0>
514 <1>
515---
516Message-Id: <3>
517In-Reply-To: <2>
518References: <0>
519 <1>
520 <2>
521EOF
522
523test_expect_success 'thread deep cover-letter' '
524 check_threading expect.deep-cl --cover-letter --thread=deep master
525'
526
527cat > expect.deep-cl-irt <<EOF
528---
529Message-Id: <0>
530In-Reply-To: <1>
531References: <1>
532---
533Message-Id: <2>
534In-Reply-To: <0>
535References: <1>
536 <0>
537---
538Message-Id: <3>
539In-Reply-To: <2>
540References: <1>
541 <0>
542 <2>
543---
544Message-Id: <4>
545In-Reply-To: <3>
546References: <1>
547 <0>
548 <2>
549 <3>
550EOF
551
552test_expect_success 'thread deep cover-letter in-reply-to' '
553 check_threading expect.deep-cl-irt --cover-letter \
554 --in-reply-to="<test.message>" --thread=deep master
555'
556
557test_expect_success 'thread via config' '
e8107155 558 test_config format.thread true &&
30984ed2
TR
559 check_threading expect.thread master
560'
561
562test_expect_success 'thread deep via config' '
e8107155 563 test_config format.thread deep &&
30984ed2
TR
564 check_threading expect.deep master
565'
566
567test_expect_success 'thread config + override' '
e8107155 568 test_config format.thread deep &&
30984ed2
TR
569 check_threading expect.thread --thread master
570'
571
572test_expect_success 'thread config + --no-thread' '
e8107155 573 test_config format.thread deep &&
30984ed2
TR
574 check_threading expect.no-threading --no-thread master
575'
576
7d812145
DB
577test_expect_success 'excessive subject' '
578
579 rm -rf patches/ &&
580 git checkout side &&
bdee9cd6 581 before=$(git hash-object file) &&
582 before=$(git rev-parse --short $before) &&
7d812145 583 for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file &&
bdee9cd6 584 after=$(git hash-object file) &&
585 after=$(git rev-parse --short $after) &&
7d812145
DB
586 git update-index file &&
587 git commit -m "This is an excessively long subject line for a message due to the habit some projects have of not having a short, one-line subject at the start of the commit message, but rather sticking a whole paragraph right at the start as the only thing in the commit message. It had better not become the filename for the patch." &&
588 git format-patch -o patches/ master..side &&
589 ls patches/0004-This-is-an-excessively-long-subject-line-for-a-messa.patch
590'
591
2fe95f49
JH
592test_expect_success 'failure to write cover-letter aborts gracefully' '
593 test_when_finished "rmdir 0000-cover-letter.patch" &&
594 mkdir 0000-cover-letter.patch &&
595 test_must_fail git format-patch --no-renames --cover-letter -1
596'
597
5d02294c 598test_expect_success 'cover-letter inherits diff options' '
5d02294c
JS
599 git mv file foo &&
600 git commit -m foo &&
5404c116 601 git format-patch --no-renames --cover-letter -1 &&
cc663d14 602 check_patch 0000-cover-letter.patch &&
9524cf29 603 ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
5d02294c 604 git format-patch --cover-letter -1 -M &&
9524cf29 605 grep "file => foo .* 0 *\$" 0000-cover-letter.patch
5d02294c
JS
606
607'
859c4fbe
JS
608
609cat > expect << EOF
610 This is an excessively long subject line for a message due to the
611 habit some projects have of not having a short, one-line subject at
612 the start of the commit message, but rather sticking a whole
613 paragraph right at the start as the only thing in the commit
614 message. It had better not become the filename for the patch.
615 foo
616
617EOF
618
619test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
620
621 git format-patch --cover-letter -2 &&
9524cf29 622 sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
3af82863 623 test_cmp expect output
859c4fbe
JS
624
625'
626
68daa64d 627cat > expect << EOF
bdee9cd6 628index $before..$after 100644
68daa64d
JK
629--- a/file
630+++ b/file
631@@ -13,4 +13,20 @@ C
632 10
633 D
634 E
635 F
636+5
637EOF
638
639test_expect_success 'format-patch respects -U' '
640
641 git format-patch -U4 -2 &&
6dd88832
JN
642 sed -e "1,/^diff/d" -e "/^+5/q" \
643 <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
644 >output &&
68daa64d
JK
645 test_cmp expect output
646
647'
648
1d46f2ea
JK
649cat > expect << EOF
650
651diff --git a/file b/file
bdee9cd6 652index $before..$after 100644
1d46f2ea
JK
653--- a/file
654+++ b/file
655@@ -14,3 +14,19 @@ C
656 D
657 E
658 F
659+5
660EOF
661
662test_expect_success 'format-patch -p suppresses stat' '
663
664 git format-patch -p -2 &&
9524cf29 665 sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
1d46f2ea
JK
666 test_cmp expect output
667
668'
669
9800a754
JH
670test_expect_success 'format-patch from a subdirectory (1)' '
671 filename=$(
672 rm -rf sub &&
673 mkdir -p sub/dir &&
674 cd sub/dir &&
675 git format-patch -1
676 ) &&
677 case "$filename" in
678 0*)
679 ;; # ok
680 *)
681 echo "Oops? $filename"
682 false
683 ;;
684 esac &&
685 test -f "$filename"
686'
687
688test_expect_success 'format-patch from a subdirectory (2)' '
689 filename=$(
690 rm -rf sub &&
691 mkdir -p sub/dir &&
692 cd sub/dir &&
693 git format-patch -1 -o ..
694 ) &&
695 case "$filename" in
696 ../0*)
697 ;; # ok
698 *)
699 echo "Oops? $filename"
700 false
701 ;;
702 esac &&
703 basename=$(expr "$filename" : ".*/\(.*\)") &&
704 test -f "sub/$basename"
705'
706
707test_expect_success 'format-patch from a subdirectory (3)' '
9800a754
JH
708 rm -f 0* &&
709 filename=$(
710 rm -rf sub &&
711 mkdir -p sub/dir &&
712 cd sub/dir &&
91c8b825 713 git format-patch -1 -o "$TRASH_DIRECTORY"
9800a754
JH
714 ) &&
715 basename=$(expr "$filename" : ".*/\(.*\)") &&
716 test -f "$basename"
717'
718
f044fe2d
SB
719test_expect_success 'format-patch --in-reply-to' '
720 git format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 &&
721 grep "^In-Reply-To: <baz@foo.bar>" patch8 &&
722 grep "^References: <baz@foo.bar>" patch8
723'
724
725test_expect_success 'format-patch --signoff' '
212620fe
JH
726 git format-patch -1 --signoff --stdout >out &&
727 grep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" out
728'
729
730test_expect_success 'format-patch --notes --signoff' '
731 git notes --ref test add -m "test message" HEAD &&
732 git format-patch -1 --signoff --stdout --notes=test >out &&
bd1470b8 733 # Three dashes must come after S-o-b
212620fe 734 ! sed "/^Signed-off-by: /q" out | grep "test message" &&
bd1470b8
JH
735 sed "1,/^Signed-off-by: /d" out | grep "test message" &&
736 # Notes message must come after three dashes
737 ! sed "/^---$/q" out | grep "test message" &&
738 sed "1,/^---$/d" out | grep "test message"
f044fe2d
SB
739'
740
13cdf780
DL
741test_expect_success 'format-patch notes output control' '
742 git notes add -m "notes config message" HEAD &&
743 test_when_finished git notes remove HEAD &&
744
745 git format-patch -1 --stdout >out &&
746 ! grep "notes config message" out &&
747 git format-patch -1 --stdout --notes >out &&
748 grep "notes config message" out &&
749 git format-patch -1 --stdout --no-notes >out &&
750 ! grep "notes config message" out &&
751 git format-patch -1 --stdout --notes --no-notes >out &&
752 ! grep "notes config message" out &&
753 git format-patch -1 --stdout --no-notes --notes >out &&
754 grep "notes config message" out &&
755
756 test_config format.notes true &&
757 git format-patch -1 --stdout >out &&
758 grep "notes config message" out &&
759 git format-patch -1 --stdout --notes >out &&
760 grep "notes config message" out &&
761 git format-patch -1 --stdout --no-notes >out &&
762 ! grep "notes config message" out &&
763 git format-patch -1 --stdout --notes --no-notes >out &&
764 ! grep "notes config message" out &&
765 git format-patch -1 --stdout --no-notes --notes >out &&
766 grep "notes config message" out
767'
768
769test_expect_success 'format-patch with multiple notes refs' '
770 git notes --ref note1 add -m "this is note 1" HEAD &&
771 test_when_finished git notes --ref note1 remove HEAD &&
772 git notes --ref note2 add -m "this is note 2" HEAD &&
773 test_when_finished git notes --ref note2 remove HEAD &&
774
775 git format-patch -1 --stdout >out &&
776 ! grep "this is note 1" out &&
777 ! grep "this is note 2" out &&
778 git format-patch -1 --stdout --notes=note1 >out &&
779 grep "this is note 1" out &&
780 ! grep "this is note 2" out &&
781 git format-patch -1 --stdout --notes=note2 >out &&
782 ! grep "this is note 1" out &&
783 grep "this is note 2" out &&
784 git format-patch -1 --stdout --notes=note1 --notes=note2 >out &&
785 grep "this is note 1" out &&
786 grep "this is note 2" out &&
787
788 test_config format.notes note1 &&
789 git format-patch -1 --stdout >out &&
790 grep "this is note 1" out &&
791 ! grep "this is note 2" out &&
792 git format-patch -1 --stdout --no-notes >out &&
793 ! grep "this is note 1" out &&
794 ! grep "this is note 2" out &&
795 git format-patch -1 --stdout --notes=note2 >out &&
796 grep "this is note 1" out &&
797 grep "this is note 2" out &&
798 git format-patch -1 --stdout --no-notes --notes=note2 >out &&
799 ! grep "this is note 1" out &&
800 grep "this is note 2" out &&
801
802 git config --add format.notes note2 &&
803 git format-patch -1 --stdout >out &&
804 grep "this is note 1" out &&
805 grep "this is note 2" out &&
806 git format-patch -1 --stdout --no-notes >out &&
807 ! grep "this is note 1" out &&
808 ! grep "this is note 2" out
809'
810
02bc5b03
BG
811echo "fatal: --name-only does not make sense" > expect.name-only
812echo "fatal: --name-status does not make sense" > expect.name-status
813echo "fatal: --check does not make sense" > expect.check
814
68b2a005 815test_expect_success 'options no longer allowed for format-patch' '
02bc5b03 816 test_must_fail git format-patch --name-only 2> output &&
68b2a005 817 test_i18ncmp expect.name-only output &&
02bc5b03 818 test_must_fail git format-patch --name-status 2> output &&
68b2a005 819 test_i18ncmp expect.name-status output &&
02bc5b03 820 test_must_fail git format-patch --check 2> output &&
68b2a005 821 test_i18ncmp expect.check output'
02bc5b03
BG
822
823test_expect_success 'format-patch --numstat should produce a patch' '
4fa80cf0 824 git format-patch --numstat --stdout master..side > output &&
5404c116 825 test 5 = $(grep "^diff --git a/" output | wc -l)'
02bc5b03 826
7e93d3b9
FC
827test_expect_success 'format-patch -- <path>' '
828 git format-patch master..side -- file 2>error &&
829 ! grep "Use .--" error
830'
831
657ab61e
KB
832test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
833 git format-patch --ignore-if-in-upstream HEAD
834'
835
480871e0
JT
836git_version="$(git --version | sed "s/.* //")"
837
838signature() {
839 printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
840}
841
842test_expect_success 'format-patch default signature' '
843 git format-patch --stdout -1 | tail -n 3 >output &&
844 signature >expect &&
845 test_cmp expect output
846'
847
6622d9c7 848test_expect_success 'format-patch --signature' '
480871e0
JT
849 git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
850 signature "my sig" >expect &&
851 test_cmp expect output
6622d9c7
SB
852'
853
854test_expect_success 'format-patch with format.signature config' '
855 git config format.signature "config sig" &&
856 git format-patch --stdout -1 >output &&
857 grep "config sig" output
858'
859
860test_expect_success 'format-patch --signature overrides format.signature' '
861 git config format.signature "config sig" &&
862 git format-patch --stdout --signature="overrides" -1 >output &&
863 ! grep "config sig" output &&
864 grep "overrides" output
865'
866
867test_expect_success 'format-patch --no-signature ignores format.signature' '
868 git config format.signature "config sig" &&
869 git format-patch --stdout --signature="my sig" --no-signature \
870 -1 >output &&
cc663d14 871 check_patch output &&
6622d9c7
SB
872 ! grep "config sig" output &&
873 ! grep "my sig" output &&
874 ! grep "^-- \$" output
875'
876
877test_expect_success 'format-patch --signature --cover-letter' '
878 git config --unset-all format.signature &&
879 git format-patch --stdout --signature="my sig" --cover-letter \
880 -1 >output &&
881 grep "my sig" output &&
882 test 2 = $(grep "my sig" output | wc -l)
883'
884
41ccfdd9 885test_expect_success 'format.signature="" suppresses signatures' '
6622d9c7
SB
886 git config format.signature "" &&
887 git format-patch --stdout -1 >output &&
cc663d14 888 check_patch output &&
6622d9c7
SB
889 ! grep "^-- \$" output
890'
891
41ccfdd9 892test_expect_success 'format-patch --no-signature suppresses signatures' '
6622d9c7
SB
893 git config --unset-all format.signature &&
894 git format-patch --stdout --no-signature -1 >output &&
cc663d14 895 check_patch output &&
6622d9c7
SB
896 ! grep "^-- \$" output
897'
898
41ccfdd9 899test_expect_success 'format-patch --signature="" suppresses signatures' '
2fdb5c62 900 git format-patch --stdout --signature="" -1 >output &&
cc663d14 901 check_patch output &&
6622d9c7
SB
902 ! grep "^-- \$" output
903'
904
7022650f
JM
905test_expect_success 'prepare mail-signature input' '
906 cat >mail-signature <<-\EOF
907
908 Test User <test.email@kernel.org>
909 http://git.kernel.org/cgit/git/git.git
910
911 git.kernel.org/?p=git/git.git;a=summary
912
913 EOF
914'
915
916test_expect_success '--signature-file=file works' '
917 git format-patch --stdout --signature-file=mail-signature -1 >output &&
918 check_patch output &&
919 sed -e "1,/^-- \$/d" <output >actual &&
920 {
921 cat mail-signature && echo
922 } >expect &&
923 test_cmp expect actual
924'
925
926test_expect_success 'format.signaturefile works' '
927 test_config format.signaturefile mail-signature &&
928 git format-patch --stdout -1 >output &&
929 check_patch output &&
930 sed -e "1,/^-- \$/d" <output >actual &&
931 {
932 cat mail-signature && echo
933 } >expect &&
934 test_cmp expect actual
935'
936
937test_expect_success '--no-signature suppresses format.signaturefile ' '
938 test_config format.signaturefile mail-signature &&
939 git format-patch --stdout --no-signature -1 >output &&
940 check_patch output &&
941 ! grep "^-- \$" output
942'
943
944test_expect_success '--signature-file overrides format.signaturefile' '
99094a7a 945 cat >other-mail-signature <<-\EOF &&
7022650f
JM
946 Use this other signature instead of mail-signature.
947 EOF
948 test_config format.signaturefile mail-signature &&
949 git format-patch --stdout \
950 --signature-file=other-mail-signature -1 >output &&
951 check_patch output &&
952 sed -e "1,/^-- \$/d" <output >actual &&
953 {
954 cat other-mail-signature && echo
955 } >expect &&
956 test_cmp expect actual
957'
958
959test_expect_success '--signature overrides format.signaturefile' '
960 test_config format.signaturefile mail-signature &&
961 git format-patch --stdout --signature="my sig" -1 >output &&
962 check_patch output &&
963 grep "my sig" output
964'
965
38a94bb6
TRC
966test_expect_success TTY 'format-patch --stdout paginates' '
967 rm -f pager_used &&
512477b1 968 test_terminal env GIT_PAGER="wc >pager_used" git format-patch --stdout --all &&
38a94bb6
TRC
969 test_path_is_file pager_used
970'
971
972 test_expect_success TTY 'format-patch --stdout pagination can be disabled' '
973 rm -f pager_used &&
512477b1
DT
974 test_terminal env GIT_PAGER="wc >pager_used" git --no-pager format-patch --stdout --all &&
975 test_terminal env GIT_PAGER="wc >pager_used" git -c "pager.format-patch=false" format-patch --stdout --all &&
38a94bb6
TRC
976 test_path_is_missing pager_used &&
977 test_path_is_missing .git/pager_used
978'
979
a1f6baa5
JK
980test_expect_success 'format-patch handles multi-line subjects' '
981 rm -rf patches/ &&
982 echo content >>file &&
983 for i in one two three; do echo $i; done >msg &&
984 git add file &&
985 git commit -F msg &&
986 git format-patch -o patches -1 &&
987 grep ^Subject: patches/0001-one.patch >actual &&
988 echo "Subject: [PATCH] one two three" >expect &&
989 test_cmp expect actual
990'
991
992test_expect_success 'format-patch handles multi-line encoded subjects' '
993 rm -rf patches/ &&
994 echo content >>file &&
995 for i in en två tre; do echo $i; done >msg &&
996 git add file &&
997 git commit -F msg &&
998 git format-patch -o patches -1 &&
999 grep ^Subject: patches/0001-en.patch >actual &&
1000 echo "Subject: [PATCH] =?UTF-8?q?en=20tv=C3=A5=20tre?=" >expect &&
1001 test_cmp expect actual
1002'
1003
1004M8="foo bar "
1005M64=$M8$M8$M8$M8$M8$M8$M8$M8
1006M512=$M64$M64$M64$M64$M64$M64$M64$M64
1007cat >expect <<'EOF'
1008Subject: [PATCH] foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo
7a76e68a
JS
1009 bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
1010 foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo
1011 bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
1012 foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo
1013 bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
1014 foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
a1f6baa5 1015EOF
7a76e68a 1016test_expect_success 'format-patch wraps extremely long subject (ascii)' '
a1f6baa5
JK
1017 echo content >>file &&
1018 git add file &&
1019 git commit -m "$M512" &&
1020 git format-patch --stdout -1 >patch &&
1021 sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
1022 test_cmp expect subject
1023'
1024
1025M8="föö bar "
1026M64=$M8$M8$M8$M8$M8$M8$M8$M8
1027M512=$M64$M64$M64$M64$M64$M64$M64$M64
1028cat >expect <<'EOF'
94f6cdf6
JS
1029Subject: [PATCH] =?UTF-8?q?f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
1030 =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
1031 =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
1032 =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
6cd3c053
KS
1033 =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
1034 =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
94f6cdf6
JS
1035 =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
1036 =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
1037 =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
6cd3c053
KS
1038 =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
1039 =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
94f6cdf6
JS
1040 =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
1041 =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
1042 =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
6cd3c053
KS
1043 =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
1044 =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
1045 =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
1046 =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
1047 =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
1048 =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
1049 =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
1050 =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
1051 =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
1052 =?UTF-8?q?bar?=
a1f6baa5 1053EOF
94f6cdf6 1054test_expect_success 'format-patch wraps extremely long subject (rfc2047)' '
a1f6baa5
JK
1055 rm -rf patches/ &&
1056 echo content >>file &&
1057 git add file &&
1058 git commit -m "$M512" &&
1059 git format-patch --stdout -1 >patch &&
1060 sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
1061 test_cmp expect subject
1062'
1063
4d03c18a
JK
1064check_author() {
1065 echo content >>file &&
1066 git add file &&
1067 GIT_AUTHOR_NAME=$1 git commit -m author-check &&
1068 git format-patch --stdout -1 >patch &&
7a76e68a 1069 sed -n "/^From: /p; /^ /p; /^$/q" <patch >actual &&
4d03c18a
JK
1070 test_cmp expect actual
1071}
1072
1073cat >expect <<'EOF'
1074From: "Foo B. Bar" <author@example.com>
1075EOF
0fcec2ce 1076test_expect_success 'format-patch quotes dot in from-headers' '
4d03c18a
JK
1077 check_author "Foo B. Bar"
1078'
1079
1080cat >expect <<'EOF'
1081From: "Foo \"The Baz\" Bar" <author@example.com>
1082EOF
0fcec2ce 1083test_expect_success 'format-patch quotes double-quote in from-headers' '
4d03c18a
JK
1084 check_author "Foo \"The Baz\" Bar"
1085'
1086
1087cat >expect <<'EOF'
0fcec2ce 1088From: =?UTF-8?q?F=C3=B6o=20Bar?= <author@example.com>
4d03c18a 1089EOF
0fcec2ce
JS
1090test_expect_success 'format-patch uses rfc2047-encoded from-headers when necessary' '
1091 check_author "Föo Bar"
1092'
1093
1094cat >expect <<'EOF'
1095From: =?UTF-8?q?F=C3=B6o=20B=2E=20Bar?= <author@example.com>
1096EOF
41dd00ba 1097test_expect_success 'rfc2047-encoded from-headers leave no rfc822 specials' '
4d03c18a
JK
1098 check_author "Föo B. Bar"
1099'
1100
7a76e68a
JS
1101cat >expect <<EOF
1102From: foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_
1103 <author@example.com>
1104EOF
1105test_expect_success 'format-patch wraps moderately long from-header (ascii)' '
1106 check_author "foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_"
1107'
1108
1109cat >expect <<'EOF'
1110From: Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar
1111 Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo
1112 Bar Foo Bar Foo Bar Foo Bar <author@example.com>
1113EOF
1114test_expect_success 'format-patch wraps extremely long from-header (ascii)' '
1115 check_author "Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar"
1116'
1117
1118cat >expect <<'EOF'
1119From: "Foo.Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar
1120 Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo
1121 Bar Foo Bar Foo Bar Foo Bar" <author@example.com>
1122EOF
1123test_expect_success 'format-patch wraps extremely long from-header (rfc822)' '
1124 check_author "Foo.Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar"
1125'
1126
4d03c18a 1127cat >expect <<'EOF'
94f6cdf6
JS
1128From: =?UTF-8?q?Fo=C3=B6=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo?=
1129 =?UTF-8?q?=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20?=
1130 =?UTF-8?q?Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar?=
1131 =?UTF-8?q?=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20?=
1132 =?UTF-8?q?Foo=20Bar=20Foo=20Bar?= <author@example.com>
1133EOF
1134test_expect_success 'format-patch wraps extremely long from-header (rfc2047)' '
1135 check_author "Foö Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar"
1136'
1137
1138cat >expect <<'EOF'
4d03c18a
JK
1139Subject: header with . in it
1140EOF
1141test_expect_success 'subject lines do not have 822 atom-quoting' '
1142 echo content >>file &&
1143 git add file &&
1144 git commit -m "header with . in it" &&
1145 git format-patch -k -1 --stdout >patch &&
1146 grep ^Subject: patch >actual &&
1147 test_cmp expect actual
1148'
1149
e7af8e49
JK
1150cat >expect <<'EOF'
1151Subject: [PREFIX 1/1] header with . in it
1152EOF
1153test_expect_success 'subject prefixes have space prepended' '
1154 git format-patch -n -1 --stdout --subject-prefix=PREFIX >patch &&
1155 grep ^Subject: patch >actual &&
1156 test_cmp expect actual
1157'
1158
1159cat >expect <<'EOF'
1160Subject: [1/1] header with . in it
1161EOF
1162test_expect_success 'empty subject prefix does not have extra space' '
1163 git format-patch -n -1 --stdout --subject-prefix= >patch &&
1164 grep ^Subject: patch >actual &&
1165 test_cmp expect actual
1166'
1167
68e83a5b
JT
1168test_expect_success '--rfc' '
1169 cat >expect <<-\EOF &&
1170 Subject: [RFC PATCH 1/1] header with . in it
1171 EOF
1172 git format-patch -n -1 --stdout --rfc >patch &&
1173 grep ^Subject: patch >actual &&
1174 test_cmp expect actual
1175'
1176
a9080475
JK
1177test_expect_success '--from=ident notices bogus ident' '
1178 test_must_fail git format-patch -1 --stdout --from=foo >patch
1179'
1180
1181test_expect_success '--from=ident replaces author' '
1182 git format-patch -1 --stdout --from="Me <me@example.com>" >patch &&
1183 cat >expect <<-\EOF &&
1184 From: Me <me@example.com>
1185
1186 From: A U Thor <author@example.com>
1187
1188 EOF
1189 sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
1190 test_cmp expect patch.head
1191'
1192
1193test_expect_success '--from uses committer ident' '
1194 git format-patch -1 --stdout --from >patch &&
1195 cat >expect <<-\EOF &&
1196 From: C O Mitter <committer@example.com>
1197
1198 From: A U Thor <author@example.com>
1199
1200 EOF
1201 sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
1202 test_cmp expect patch.head
1203'
1204
662cc30c
JK
1205test_expect_success '--from omits redundant in-body header' '
1206 git format-patch -1 --stdout --from="A U Thor <author@example.com>" >patch &&
1207 cat >expect <<-\EOF &&
1208 From: A U Thor <author@example.com>
1209
1210 EOF
1211 sed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&
1212 test_cmp expect patch.head
1213'
1214
a9080475 1215test_expect_success 'in-body headers trigger content encoding' '
d2554c72 1216 test_env GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&
a9080475
JK
1217 test_when_finished "git reset --hard HEAD^" &&
1218 git format-patch -1 --stdout --from >patch &&
1219 cat >expect <<-\EOF &&
1220 From: C O Mitter <committer@example.com>
1221 Content-Type: text/plain; charset=UTF-8
1222
1223 From: éxötìc <author@example.com>
1224
1225 EOF
1226 sed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" <patch >patch.head &&
1227 test_cmp expect patch.head
1228'
1229
79133a66
NTND
1230append_signoff()
1231{
1232 C=$(git commit-tree HEAD^^{tree} -p HEAD) &&
1233 git format-patch --stdout --signoff $C^..$C >append_signoff.patch &&
1234 sed -n -e "1,/^---$/p" append_signoff.patch |
1235 egrep -n "^Subject|Sign|^$"
1236}
1237
1238test_expect_success 'signoff: commit with no body' '
1239 append_signoff </dev/null >actual &&
1240 cat <<\EOF | sed "s/EOL$//" >expected &&
12414:Subject: [PATCH] EOL
12428:
12439:Signed-off-by: C O Mitter <committer@example.com>
1244EOF
1245 test_cmp expected actual
1246'
1247
1248test_expect_success 'signoff: commit with only subject' '
1249 echo subject | append_signoff >actual &&
1250 cat >expected <<\EOF &&
12514:Subject: [PATCH] subject
12528:
12539:Signed-off-by: C O Mitter <committer@example.com>
1254EOF
1255 test_cmp expected actual
1256'
1257
1258test_expect_success 'signoff: commit with only subject that does not end with NL' '
1259 printf subject | append_signoff >actual &&
1260 cat >expected <<\EOF &&
12614:Subject: [PATCH] subject
12628:
12639:Signed-off-by: C O Mitter <committer@example.com>
1264EOF
1265 test_cmp expected actual
1266'
1267
1268test_expect_success 'signoff: no existing signoffs' '
1269 append_signoff <<\EOF >actual &&
1270subject
1271
1272body
1273EOF
1274 cat >expected <<\EOF &&
12754:Subject: [PATCH] subject
12768:
127710:
127811:Signed-off-by: C O Mitter <committer@example.com>
1279EOF
1280 test_cmp expected actual
1281'
1282
1283test_expect_success 'signoff: no existing signoffs and no trailing NL' '
1284 printf "subject\n\nbody" | append_signoff >actual &&
1285 cat >expected <<\EOF &&
12864:Subject: [PATCH] subject
12878:
128810:
128911:Signed-off-by: C O Mitter <committer@example.com>
1290EOF
1291 test_cmp expected actual
1292'
1293
1294test_expect_success 'signoff: some random signoff' '
1295 append_signoff <<\EOF >actual &&
1296subject
1297
1298body
1299
1300Signed-off-by: my@house
1301EOF
1302 cat >expected <<\EOF &&
13034:Subject: [PATCH] subject
13048:
130510:
130611:Signed-off-by: my@house
130712:Signed-off-by: C O Mitter <committer@example.com>
1308EOF
1309 test_cmp expected actual
1310'
1311
959a2623
BC
1312test_expect_success 'signoff: misc conforming footer elements' '
1313 append_signoff <<\EOF >actual &&
1314subject
1315
1316body
1317
1318Signed-off-by: my@house
1319(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
1320Tested-by: Some One <someone@example.com>
1321Bug: 1234
1322EOF
1323 cat >expected <<\EOF &&
13244:Subject: [PATCH] subject
13258:
132610:
132711:Signed-off-by: my@house
132815:Signed-off-by: C O Mitter <committer@example.com>
1329EOF
1330 test_cmp expected actual
1331'
1332
1333test_expect_success 'signoff: some random signoff-alike' '
79133a66
NTND
1334 append_signoff <<\EOF >actual &&
1335subject
1336
1337body
1338Fooled-by-me: my@house
1339EOF
1340 cat >expected <<\EOF &&
13414:Subject: [PATCH] subject
13428:
134311:
134412:Signed-off-by: C O Mitter <committer@example.com>
1345EOF
1346 test_cmp expected actual
1347'
1348
959a2623 1349test_expect_success 'signoff: not really a signoff' '
79133a66
NTND
1350 append_signoff <<\EOF >actual &&
1351subject
1352
1353I want to mention about Signed-off-by: here.
1354EOF
1355 cat >expected <<\EOF &&
13564:Subject: [PATCH] subject
13578:
13589:I want to mention about Signed-off-by: here.
135910:
136011:Signed-off-by: C O Mitter <committer@example.com>
1361EOF
1362 test_cmp expected actual
1363'
1364
959a2623 1365test_expect_success 'signoff: not really a signoff (2)' '
79133a66
NTND
1366 append_signoff <<\EOF >actual &&
1367subject
1368
1369My unfortunate
1370Signed-off-by: example happens to be wrapped here.
1371EOF
1372 cat >expected <<\EOF &&
13734:Subject: [PATCH] subject
13748:
137510:Signed-off-by: example happens to be wrapped here.
967dfd4d 137611:Signed-off-by: C O Mitter <committer@example.com>
79133a66
NTND
1377EOF
1378 test_cmp expected actual
1379'
1380
959a2623 1381test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
79133a66
NTND
1382 append_signoff <<\EOF >actual &&
1383subject
1384
1385Signed-off-by: my@house
1386Signed-off-by: your@house
1387
1388A lot of houses.
1389EOF
1390 cat >expected <<\EOF &&
13914:Subject: [PATCH] subject
13928:
13939:Signed-off-by: my@house
139410:Signed-off-by: your@house
139511:
139613:
139714:Signed-off-by: C O Mitter <committer@example.com>
1398EOF
1399 test_cmp expected actual
1400'
1401
1402test_expect_success 'signoff: the same signoff at the end' '
1403 append_signoff <<\EOF >actual &&
1404subject
1405
1406body
1407
1408Signed-off-by: C O Mitter <committer@example.com>
1409EOF
1410 cat >expected <<\EOF &&
14114:Subject: [PATCH] subject
14128:
141310:
141411:Signed-off-by: C O Mitter <committer@example.com>
1415EOF
1416 test_cmp expected actual
1417'
1418
1419test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
1420 printf "subject\n\nSigned-off-by: C O Mitter <committer@example.com>" |
1421 append_signoff >actual &&
1422 cat >expected <<\EOF &&
14234:Subject: [PATCH] subject
14248:
14259:Signed-off-by: C O Mitter <committer@example.com>
1426EOF
1427 test_cmp expected actual
1428'
1429
1430test_expect_success 'signoff: the same signoff NOT at the end' '
1431 append_signoff <<\EOF >actual &&
1432subject
1433
1434body
1435
1436Signed-off-by: C O Mitter <committer@example.com>
1437Signed-off-by: my@house
1438EOF
1439 cat >expected <<\EOF &&
14404:Subject: [PATCH] subject
14418:
144210:
144311:Signed-off-by: C O Mitter <committer@example.com>
144412:Signed-off-by: my@house
1445EOF
1446 test_cmp expected actual
1447'
1448
967dfd4d 1449test_expect_success 'signoff: tolerate garbage in conforming footer' '
79133a66
NTND
1450 append_signoff <<\EOF >actual &&
1451subject
1452
1453body
1454
1455Tested-by: my@house
1456Some Trash
1457Signed-off-by: C O Mitter <committer@example.com>
1458EOF
1459 cat >expected <<\EOF &&
14604:Subject: [PATCH] subject
14618:
146210:
146313:Signed-off-by: C O Mitter <committer@example.com>
967dfd4d
JT
1464EOF
1465 test_cmp expected actual
1466'
1467
1468test_expect_success 'signoff: respect trailer config' '
1469 append_signoff <<\EOF >actual &&
1470subject
1471
1472Myfooter: x
1473Some Trash
1474EOF
1475 cat >expected <<\EOF &&
14764:Subject: [PATCH] subject
14778:
147811:
147912:Signed-off-by: C O Mitter <committer@example.com>
1480EOF
1481 test_cmp expected actual &&
1482
1483 test_config trailer.Myfooter.ifexists add &&
1484 append_signoff <<\EOF >actual &&
1485subject
1486
1487Myfooter: x
1488Some Trash
1489EOF
1490 cat >expected <<\EOF &&
14914:Subject: [PATCH] subject
14928:
149311:Signed-off-by: C O Mitter <committer@example.com>
79133a66
NTND
1494EOF
1495 test_cmp expected actual
1496'
1497
1498test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
1499 append_signoff <<\EOF >actual &&
1500subject
1501
1502body
1503
1504Reviewed-id: Noone
1505Tested-by: my@house
1506Change-id: Ideadbeef
1507Signed-off-by: C O Mitter <committer@example.com>
1508Bug: 1234
1509EOF
1510 cat >expected <<\EOF &&
15114:Subject: [PATCH] subject
15128:
151310:
151414:Signed-off-by: C O Mitter <committer@example.com>
1515EOF
1516 test_cmp expected actual
1517'
1518
787570c7
PYH
1519test_expect_success 'format patch ignores color.ui' '
1520 test_unconfig color.ui &&
1521 git format-patch --stdout -1 >expect &&
1522 test_config color.ui always &&
1523 git format-patch --stdout -1 >actual &&
1524 test_cmp expect actual
1525'
1526
e216cc48
NTND
1527test_expect_success 'cover letter using branch description (1)' '
1528 git checkout rebuild-1 &&
1529 test_config branch.rebuild-1.description hello &&
1530 git format-patch --stdout --cover-letter master >actual &&
1531 grep hello actual >/dev/null
1532'
1533
1534test_expect_success 'cover letter using branch description (2)' '
1535 git checkout rebuild-1 &&
1536 test_config branch.rebuild-1.description hello &&
1537 git format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&
1538 grep hello actual >/dev/null
1539'
1540
1541test_expect_success 'cover letter using branch description (3)' '
1542 git checkout rebuild-1 &&
1543 test_config branch.rebuild-1.description hello &&
1544 git format-patch --stdout --cover-letter ^master rebuild-1 >actual &&
1545 grep hello actual >/dev/null
1546'
1547
20b630aa
NTND
1548test_expect_success 'cover letter using branch description (4)' '
1549 git checkout rebuild-1 &&
1550 test_config branch.rebuild-1.description hello &&
1551 git format-patch --stdout --cover-letter master.. >actual &&
1552 grep hello actual >/dev/null
1553'
1554
1555test_expect_success 'cover letter using branch description (5)' '
1556 git checkout rebuild-1 &&
1557 test_config branch.rebuild-1.description hello &&
1558 git format-patch --stdout --cover-letter -2 HEAD >actual &&
1559 grep hello actual >/dev/null
1560'
1561
5ee29aef
NTND
1562test_expect_success 'cover letter using branch description (6)' '
1563 git checkout rebuild-1 &&
1564 test_config branch.rebuild-1.description hello &&
1565 git format-patch --stdout --cover-letter -2 >actual &&
1566 grep hello actual >/dev/null
1567'
1568
80d35ca0
FC
1569test_expect_success 'cover letter with nothing' '
1570 git format-patch --stdout --cover-letter >actual &&
1571 test_line_count = 0 actual
1572'
1573
2a4c2607
FC
1574test_expect_success 'cover letter auto' '
1575 mkdir -p tmp &&
1576 test_when_finished "rm -rf tmp;
1577 git config --unset format.coverletter" &&
1578
1579 git config format.coverletter auto &&
1580 git format-patch -o tmp -1 >list &&
1581 test_line_count = 1 list &&
1582 git format-patch -o tmp -2 >list &&
1583 test_line_count = 3 list
1584'
1585
1586test_expect_success 'cover letter auto user override' '
1587 mkdir -p tmp &&
1588 test_when_finished "rm -rf tmp;
1589 git config --unset format.coverletter" &&
1590
1591 git config format.coverletter auto &&
1592 git format-patch -o tmp --cover-letter -1 >list &&
1593 test_line_count = 2 list &&
1594 git format-patch -o tmp --cover-letter -2 >list &&
1595 test_line_count = 3 list &&
1596 git format-patch -o tmp --no-cover-letter -1 >list &&
1597 test_line_count = 1 list &&
1598 git format-patch -o tmp --no-cover-letter -2 >list &&
1599 test_line_count = 2 list
1600'
1601
3a30aa17 1602test_expect_success 'format-patch --zero-commit' '
1603 git format-patch --zero-commit --stdout v2..v1 >patch2 &&
1604 grep "^From " patch2 | sort | uniq >actual &&
8125a58b 1605 echo "From $ZERO_OID Mon Sep 17 00:00:00 2001" >expect &&
3a30aa17 1606 test_cmp expect actual
1607'
1608
06dfc9eb 1609test_expect_success 'From line has expected format' '
1610 git format-patch --stdout v2..v1 >patch2 &&
1611 grep "^From " patch2 >from &&
2ece6ad2 1612 grep "^From $OID_REGEX Mon Sep 17 00:00:00 2001$" patch2 >filtered &&
06dfc9eb 1613 test_cmp from filtered
1614'
1615
bc6bf2d7
AK
1616test_expect_success 'format-patch format.outputDirectory option' '
1617 test_config format.outputDirectory patches &&
1618 rm -fr patches &&
1619 git format-patch master..side &&
1620 test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)
1621'
1622
1623test_expect_success 'format-patch -o overrides format.outputDirectory' '
1624 test_config format.outputDirectory patches &&
1625 rm -fr patches patchset &&
1626 git format-patch master..side -o patchset &&
1627 test_path_is_missing patches &&
1628 test_path_is_dir patchset
1629'
1630
fa2ab86d
XY
1631test_expect_success 'format-patch --base' '
1632 git checkout side &&
15b76c1f
XY
1633 git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
1634 git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
480871e0
JT
1635 echo >expected &&
1636 echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
fa2ab86d
XY
1637 echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
1638 echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
480871e0 1639 signature >> expected &&
15b76c1f
XY
1640 test_cmp expected actual1 &&
1641 test_cmp expected actual2
fa2ab86d
XY
1642'
1643
1644test_expect_success 'format-patch --base errors out when base commit is in revision list' '
1645 test_must_fail git format-patch --base=HEAD -2 &&
1646 test_must_fail git format-patch --base=HEAD~1 -2 &&
1647 git format-patch --stdout --base=HEAD~2 -2 >patch &&
1648 grep "^base-commit:" patch >actual &&
1649 echo "base-commit: $(git rev-parse HEAD~2)" >expected &&
1650 test_cmp expected actual
1651'
1652
1653test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' '
1654 # For history as below:
1655 #
1656 # ---Q---P---Z---Y---*---X
1657 # \ /
1658 # ------------W
1659 #
1660 # If "format-patch Z..X" is given, P and Z can not be specified as the base commit
1661 git checkout -b topic1 master &&
1662 git rev-parse HEAD >commit-id-base &&
1663 test_commit P &&
1664 git rev-parse HEAD >commit-id-P &&
1665 test_commit Z &&
1666 git rev-parse HEAD >commit-id-Z &&
1667 test_commit Y &&
1668 git checkout -b topic2 master &&
1669 test_commit W &&
1670 git merge topic1 &&
1671 test_commit X &&
1672 test_must_fail git format-patch --base=$(cat commit-id-P) -3 &&
1673 test_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&
1674 git format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&
1675 grep "^base-commit:" patch >actual &&
1676 echo "base-commit: $(cat commit-id-base)" >expected &&
1677 test_cmp expected actual
1678'
1679
3de66517
XY
1680test_expect_success 'format-patch --base=auto' '
1681 git checkout -b upstream master &&
1682 git checkout -b local upstream &&
1683 git branch --set-upstream-to=upstream &&
1684 test_commit N1 &&
1685 test_commit N2 &&
1686 git format-patch --stdout --base=auto -2 >patch &&
1687 grep "^base-commit:" patch >actual &&
1688 echo "base-commit: $(git rev-parse upstream)" >expected &&
1689 test_cmp expected actual
1690'
1691
1692test_expect_success 'format-patch errors out when history involves criss-cross' '
1693 # setup criss-cross history
1694 #
1695 # B---M1---D
1696 # / \ /
1697 # A X
1698 # \ / \
1699 # C---M2---E
1700 #
1701 git checkout master &&
1702 test_commit A &&
1703 git checkout -b xb master &&
1704 test_commit B &&
1705 git checkout -b xc master &&
1706 test_commit C &&
1707 git checkout -b xbc xb -- &&
1708 git merge xc &&
1709 git checkout -b xcb xc -- &&
1710 git branch --set-upstream-to=xbc &&
1711 git merge xb &&
1712 git checkout xbc &&
1713 test_commit D &&
1714 git checkout xcb &&
1715 test_commit E &&
1716 test_must_fail git format-patch --base=auto -1
1717'
1718
bb52995f
XY
1719test_expect_success 'format-patch format.useAutoBaseoption' '
1720 test_when_finished "git config --unset format.useAutoBase" &&
1721 git checkout local &&
1722 git config format.useAutoBase true &&
1723 git format-patch --stdout -1 >patch &&
1724 grep "^base-commit:" patch >actual &&
1725 echo "base-commit: $(git rev-parse upstream)" >expected &&
1726 test_cmp expected actual
1727'
1728
1729test_expect_success 'format-patch --base overrides format.useAutoBase' '
1730 test_when_finished "git config --unset format.useAutoBase" &&
1731 git config format.useAutoBase true &&
1732 git format-patch --stdout --base=HEAD~1 -1 >patch &&
1733 grep "^base-commit:" patch >actual &&
1734 echo "base-commit: $(git rev-parse HEAD~1)" >expected &&
1735 test_cmp expected actual
1736'
1737
480871e0
JT
1738test_expect_success 'format-patch --base with --attach' '
1739 git format-patch --attach=mimemime --stdout --base=HEAD~ -1 >patch &&
1740 sed -n -e "/^base-commit:/s/.*/1/p" -e "/^---*mimemime--$/s/.*/2/p" \
1741 patch >actual &&
1742 test_write_lines 1 2 >expect &&
1743 test_cmp expect actual
1744'
50cd54ef 1745test_expect_success 'format-patch --attach cover-letter only is non-multipart' '
1746 test_when_finished "rm -fr patches" &&
1747 git format-patch -o patches --cover-letter --attach=mimemime --base=HEAD~ -1 &&
1748 ! egrep "^--+mimemime" patches/0000*.patch &&
1749 egrep "^--+mimemime$" patches/0001*.patch >output &&
1750 test_line_count = 2 output &&
1751 egrep "^--+mimemime--$" patches/0001*.patch >output &&
1752 test_line_count = 1 output
1753'
480871e0 1754
9f23e040
EW
1755test_expect_success 'format-patch --pretty=mboxrd' '
1756 sp=" " &&
1757 cat >msg <<-INPUT_END &&
1758 mboxrd should escape the body
1759
1760 From could trip up a loose mbox parser
1761 >From extra escape for reversibility
1762 >>From extra escape for reversibility 2
1763 from lower case not escaped
1764 Fromm bad speling not escaped
1765 From with leading space not escaped
1766
1767 F
1768 From
1769 From$sp
1770 From $sp
1771 From $sp
1772 INPUT_END
1773
1774 cat >expect <<-INPUT_END &&
1775 >From could trip up a loose mbox parser
1776 >>From extra escape for reversibility
1777 >>>From extra escape for reversibility 2
1778 from lower case not escaped
1779 Fromm bad speling not escaped
1780 From with leading space not escaped
1781
1782 F
1783 From
1784 From
1785 From
1786 From
1787 INPUT_END
1788
1789 C=$(git commit-tree HEAD^^{tree} -p HEAD <msg) &&
1790 git format-patch --pretty=mboxrd --stdout -1 $C~1..$C >patch &&
1791 git grep -h --no-index -A11 \
1792 "^>From could trip up a loose mbox parser" patch >actual &&
1793 test_cmp expect actual
1794'
1795
126facf8
ES
1796test_expect_success 'interdiff: setup' '
1797 git checkout -b boop master &&
1798 test_commit fnorp blorp &&
1799 test_commit fleep blorp
1800'
1801
1802test_expect_success 'interdiff: cover-letter' '
1803 sed "y/q/ /" >expect <<-\EOF &&
1804 +fleep
1805 --q
1806 EOF
1807 git format-patch --cover-letter --interdiff=boop~2 -1 boop &&
1808 test_i18ngrep "^Interdiff:$" 0000-cover-letter.patch &&
ee6cbf71 1809 test_i18ngrep ! "^Interdiff:$" 0001-fleep.patch &&
126facf8
ES
1810 sed "1,/^@@ /d; /^-- $/q" <0000-cover-letter.patch >actual &&
1811 test_cmp expect actual
1812'
1813
5ac290f9
ES
1814test_expect_success 'interdiff: reroll-count' '
1815 git format-patch --cover-letter --interdiff=boop~2 -v2 -1 boop &&
1816 test_i18ngrep "^Interdiff ..* v1:$" v2-0000-cover-letter.patch
1817'
1818
ee6cbf71
ES
1819test_expect_success 'interdiff: solo-patch' '
1820 cat >expect <<-\EOF &&
1821 +fleep
1822
1823 EOF
1824 git format-patch --interdiff=boop~2 -1 boop &&
1825 test_i18ngrep "^Interdiff:$" 0001-fleep.patch &&
1826 sed "1,/^ @@ /d; /^$/q" <0001-fleep.patch >actual &&
1827 test_cmp expect actual
1828'
1829
ece3c67f 1830test_done