@@ -9,7 +9,6 @@ test_description='various format-patch tests'
99. " $TEST_DIRECTORY " /lib-terminal.sh
1010
1111test_expect_success setup '
12-
1312 for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
1413 cat file >elif &&
1514 git add file elif &&
@@ -60,20 +59,16 @@ test_expect_success setup '
6059'
6160
6261test_expect_success " format-patch --ignore-if-in-upstream" '
63-
6462 git format-patch --stdout master..side >patch0 &&
6563 cnt=$(grep "^From " patch0 | wc -l) &&
6664 test $cnt = 3
67-
6865'
6966
7067test_expect_success " format-patch --ignore-if-in-upstream" '
71-
7268 git format-patch --stdout \
7369 --ignore-if-in-upstream master..side >patch1 &&
7470 cnt=$(grep "^From " patch1 | wc -l) &&
7571 test $cnt = 2
76-
7772'
7873
7974test_expect_success " format-patch --ignore-if-in-upstream handles tags" '
@@ -85,7 +80,6 @@ test_expect_success "format-patch --ignore-if-in-upstream handles tags" '
8580'
8681
8782test_expect_success " format-patch doesn't consider merge commits" '
88-
8983 git checkout -b slave master &&
9084 echo "Another line" >>file &&
9185 test_tick &&
@@ -101,42 +95,33 @@ test_expect_success "format-patch doesn't consider merge commits" '
10195'
10296
10397test_expect_success " format-patch result applies" '
104-
10598 git checkout -b rebuild-0 master &&
10699 git am -3 patch0 &&
107100 cnt=$(git rev-list master.. | wc -l) &&
108101 test $cnt = 2
109102'
110103
111104test_expect_success " format-patch --ignore-if-in-upstream result applies" '
112-
113105 git checkout -b rebuild-1 master &&
114106 git am -3 patch1 &&
115107 cnt=$(git rev-list master.. | wc -l) &&
116108 test $cnt = 2
117109'
118110
119111test_expect_success ' commit did not screw up the log message' '
120-
121112 git cat-file commit side | grep "^Side .* with .* backslash-n"
122-
123113'
124114
125115test_expect_success ' format-patch did not screw up the log message' '
126-
127116 grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
128117 grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
129-
130118'
131119
132120test_expect_success ' replay did not screw up the log message' '
133-
134121 git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
135-
136122'
137123
138124test_expect_success ' extra headers' '
139-
140125 git config format.headers "To: R E Cipient <rcipient@example.com>
141126" &&
142127 git config --add format.headers "Cc: S E Cipient <scipient@example.com>
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' '
145130 sed -e "/^\$/q" patch2 > hdrs2 &&
146131 grep "^To: R E Cipient <rcipient@example.com>\$" hdrs2 &&
147132 grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs2
148-
149133'
150134
151135test_expect_success ' extra headers without newlines' '
152-
153136 git config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" &&
154137 git config --add format.headers "Cc: S E Cipient <scipient@example.com>" &&
155138 git format-patch --stdout master..side >patch3 &&
156139 sed -e "/^\$/q" patch3 > hdrs3 &&
157140 grep "^To: R E Cipient <rcipient@example.com>\$" hdrs3 &&
158141 grep "^Cc: S E Cipient <scipient@example.com>\$" hdrs3
159-
160142'
161143
162144test_expect_success ' extra headers with multiple To:s' '
163-
164145 git config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" &&
165146 git config --add format.headers "To: S E Cipient <scipient@example.com>" &&
166147 git format-patch --stdout master..side > patch4 &&
@@ -170,71 +151,61 @@ test_expect_success 'extra headers with multiple To:s' '
170151'
171152
172153test_expect_success ' additional command line cc (ascii)' '
173-
174154 git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
175155 git format-patch --cc="S E Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
176156 grep "^Cc: R E Cipient <rcipient@example.com>,\$" patch5 &&
177157 grep "^ *S E Cipient <scipient@example.com>\$" patch5
178158'
179159
180160test_expect_failure ' additional command line cc (rfc822)' '
181-
182161 git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
183162 git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch5 &&
184163 grep "^Cc: R E Cipient <rcipient@example.com>,\$" patch5 &&
185164 grep "^ *\"S. E. Cipient\" <scipient@example.com>\$" patch5
186165'
187166
188167test_expect_success ' command line headers' '
189-
190168 git config --unset-all format.headers &&
191169 git format-patch --add-header="Cc: R E Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch6 &&
192170 grep "^Cc: R E Cipient <rcipient@example.com>\$" patch6
193171'
194172
195173test_expect_success ' configuration headers and command line headers' '
196-
197174 git config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&
198175 git format-patch --add-header="Cc: S E Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch7 &&
199176 grep "^Cc: R E Cipient <rcipient@example.com>,\$" patch7 &&
200177 grep "^ *S E Cipient <scipient@example.com>\$" patch7
201178'
202179
203180test_expect_success ' command line To: header (ascii)' '
204-
205181 git config --unset-all format.headers &&
206182 git format-patch --to="R E Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
207183 grep "^To: R E Cipient <rcipient@example.com>\$" patch8
208184'
209185
210186test_expect_failure ' command line To: header (rfc822)' '
211-
212187 git format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
213188 grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" patch8
214189'
215190
216191test_expect_failure ' command line To: header (rfc2047)' '
217-
218192 git format-patch --to="R Ä Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch8 &&
219193 grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" patch8
220194'
221195
222196test_expect_success ' configuration To: header (ascii)' '
223-
224197 git config format.to "R E Cipient <rcipient@example.com>" &&
225198 git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
226199 grep "^To: R E Cipient <rcipient@example.com>\$" patch9
227200'
228201
229202test_expect_failure ' configuration To: header (rfc822)' '
230-
231203 git config format.to "R. E. Cipient <rcipient@example.com>" &&
232204 git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
233205 grep "^To: \"R. E. Cipient\" <rcipient@example.com>\$" patch9
234206'
235207
236208test_expect_failure ' configuration To: header (rfc2047)' '
237-
238209 git config format.to "R Ä Cipient <rcipient@example.com>" &&
239210 git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
240211 grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\$" patch9
@@ -249,47 +220,41 @@ check_patch () {
249220}
250221
251222test_expect_success ' format.from=false' '
252-
253223 git -c format.from=false format-patch --stdout master..side |
254224 sed -e "/^\$/q" >patch &&
255225 check_patch patch &&
256226 ! grep "^From: C O Mitter <committer@example.com>\$" patch
257227'
258228
259229test_expect_success ' format.from=true' '
260-
261230 git -c format.from=true format-patch --stdout master..side |
262231 sed -e "/^\$/q" >patch &&
263232 check_patch patch &&
264233 grep "^From: C O Mitter <committer@example.com>\$" patch
265234'
266235
267236test_expect_success ' format.from with address' '
268-
269237 git -c format.from="F R Om <from@example.com>" format-patch --stdout master..side |
270238 sed -e "/^\$/q" >patch &&
271239 check_patch patch &&
272240 grep "^From: F R Om <from@example.com>\$" patch
273241'
274242
275243test_expect_success ' --no-from overrides format.from' '
276-
277244 git -c format.from="F R Om <from@example.com>" format-patch --no-from --stdout master..side |
278245 sed -e "/^\$/q" >patch &&
279246 check_patch patch &&
280247 ! grep "^From: F R Om <from@example.com>\$" patch
281248'
282249
283250test_expect_success ' --from overrides format.from' '
284-
285251 git -c format.from="F R Om <from@example.com>" format-patch --from --stdout master..side |
286252 sed -e "/^\$/q" >patch &&
287253 check_patch patch &&
288254 ! grep "^From: F R Om <from@example.com>\$" patch
289255'
290256
291257test_expect_success ' --no-to overrides config.to' '
292-
293258 git config --replace-all format.to \
294259 "R E Cipient <rcipient@example.com>" &&
295260 git format-patch --no-to --stdout master..side |
@@ -299,7 +264,6 @@ test_expect_success '--no-to overrides config.to' '
299264'
300265
301266test_expect_success ' --no-to and --to replaces config.to' '
302-
303267 git config --replace-all format.to \
304268 "Someone <someone@out.there>" &&
305269 git format-patch --no-to --to="Someone Else <else@out.there>" \
@@ -311,7 +275,6 @@ test_expect_success '--no-to and --to replaces config.to' '
311275'
312276
313277test_expect_success ' --no-cc overrides config.cc' '
314-
315278 git config --replace-all format.cc \
316279 "C E Cipient <rcipient@example.com>" &&
317280 git format-patch --no-cc --stdout master..side |
@@ -321,7 +284,6 @@ test_expect_success '--no-cc overrides config.cc' '
321284'
322285
323286test_expect_success ' --no-add-header overrides config.headers' '
324-
325287 git config --replace-all format.headers \
326288 "Header1: B E Cipient <rcipient@example.com>" &&
327289 git format-patch --no-add-header --stdout master..side |
@@ -331,7 +293,6 @@ test_expect_success '--no-add-header overrides config.headers' '
331293'
332294
333295test_expect_success ' multiple files' '
334-
335296 rm -rf patches/ &&
336297 git checkout side &&
337298 git format-patch -o patches/ master &&
@@ -594,7 +555,6 @@ test_expect_success 'thread config + --no-thread' '
594555'
595556
596557test_expect_success ' excessive subject' '
597-
598558 rm -rf patches/ &&
599559 git checkout side &&
600560 before=$(git hash-object file) &&
@@ -622,7 +582,6 @@ test_expect_success 'cover-letter inherits diff options' '
622582 ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
623583 git format-patch --cover-letter -1 -M &&
624584 grep "file => foo .* 0 *\$" 0000-cover-letter.patch
625-
626585'
627586
628587cat > expect << EOF
@@ -636,11 +595,9 @@ cat > expect << EOF
636595EOF
637596
638597test_expect_success ' shortlog of cover-letter wraps overly-long onelines' '
639-
640598 git format-patch --cover-letter -2 &&
641599 sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
642600 test_cmp expect output
643-
644601'
645602
646603cat > expect << EOF
@@ -656,13 +613,11 @@ index $before..$after 100644
656613EOF
657614
658615test_expect_success ' format-patch respects -U' '
659-
660616 git format-patch -U4 -2 &&
661617 sed -e "1,/^diff/d" -e "/^+5/q" \
662618 <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
663619 >output &&
664620 test_cmp expect output
665-
666621'
667622
668623cat > expect << EOF
@@ -679,11 +634,9 @@ index $before..$after 100644
679634EOF
680635
681636test_expect_success ' format-patch -p suppresses stat' '
682-
683637 git format-patch -p -2 &&
684638 sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
685639 test_cmp expect output
686-
687640'
688641
689642test_expect_success ' format-patch from a subdirectory (1)' '
0 commit comments