@@ -9,7 +9,6 @@ test_description='various format-patch tests'
9
9
. " $TEST_DIRECTORY " /lib-terminal.sh
10
10
11
11
test_expect_success setup '
12
-
13
12
for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
14
13
cat file >elif &&
15
14
git add file elif &&
@@ -60,20 +59,16 @@ test_expect_success setup '
60
59
'
61
60
62
61
test_expect_success " format-patch --ignore-if-in-upstream" '
63
-
64
62
git format-patch --stdout master..side >patch0 &&
65
63
cnt=$(grep "^From " patch0 | wc -l) &&
66
64
test $cnt = 3
67
-
68
65
'
69
66
70
67
test_expect_success " format-patch --ignore-if-in-upstream" '
71
-
72
68
git format-patch --stdout \
73
69
--ignore-if-in-upstream master..side >patch1 &&
74
70
cnt=$(grep "^From " patch1 | wc -l) &&
75
71
test $cnt = 2
76
-
77
72
'
78
73
79
74
test_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" '
85
80
'
86
81
87
82
test_expect_success " format-patch doesn't consider merge commits" '
88
-
89
83
git checkout -b slave master &&
90
84
echo "Another line" >>file &&
91
85
test_tick &&
@@ -101,42 +95,33 @@ test_expect_success "format-patch doesn't consider merge commits" '
101
95
'
102
96
103
97
test_expect_success " format-patch result applies" '
104
-
105
98
git checkout -b rebuild-0 master &&
106
99
git am -3 patch0 &&
107
100
cnt=$(git rev-list master.. | wc -l) &&
108
101
test $cnt = 2
109
102
'
110
103
111
104
test_expect_success " format-patch --ignore-if-in-upstream result applies" '
112
-
113
105
git checkout -b rebuild-1 master &&
114
106
git am -3 patch1 &&
115
107
cnt=$(git rev-list master.. | wc -l) &&
116
108
test $cnt = 2
117
109
'
118
110
119
111
test_expect_success ' commit did not screw up the log message' '
120
-
121
112
git cat-file commit side | grep "^Side .* with .* backslash-n"
122
-
123
113
'
124
114
125
115
test_expect_success ' format-patch did not screw up the log message' '
126
-
127
116
grep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&
128
117
grep "^Subject: .*Side changes #3 with .* backslash-n" patch1
129
-
130
118
'
131
119
132
120
test_expect_success ' replay did not screw up the log message' '
133
-
134
121
git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
135
-
136
122
'
137
123
138
124
test_expect_success ' extra headers' '
139
-
140
125
git config format.headers "To: R E Cipient <[email protected] >
141
126
" &&
142
127
git config --add format.headers "Cc: S E Cipient <[email protected] >
@@ -145,22 +130,18 @@ test_expect_success 'extra headers' '
145
130
sed -e "/^\$/q" patch2 > hdrs2 &&
146
131
grep "^To: R E Cipient <[email protected] >\$" hdrs2 &&
147
132
grep "^Cc: S E Cipient <[email protected] >\$" hdrs2
148
-
149
133
'
150
134
151
135
test_expect_success ' extra headers without newlines' '
152
-
153
136
git config --replace-all format.headers "To: R E Cipient <[email protected] >" &&
154
137
git config --add format.headers "Cc: S E Cipient <[email protected] >" &&
155
138
git format-patch --stdout master..side >patch3 &&
156
139
sed -e "/^\$/q" patch3 > hdrs3 &&
157
140
grep "^To: R E Cipient <[email protected] >\$" hdrs3 &&
158
141
grep "^Cc: S E Cipient <[email protected] >\$" hdrs3
159
-
160
142
'
161
143
162
144
test_expect_success ' extra headers with multiple To:s' '
163
-
164
145
git config --replace-all format.headers "To: R E Cipient <[email protected] >" &&
165
146
git config --add format.headers "To: S E Cipient <[email protected] >" &&
166
147
git format-patch --stdout master..side > patch4 &&
@@ -170,71 +151,61 @@ test_expect_success 'extra headers with multiple To:s' '
170
151
'
171
152
172
153
test_expect_success ' additional command line cc (ascii)' '
173
-
174
154
git config --replace-all format.headers "Cc: R E Cipient <[email protected] >" &&
175
155
git format-patch --cc="S E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch5 &&
176
156
grep "^Cc: R E Cipient <[email protected] >,\$" patch5 &&
177
157
grep "^ *S E Cipient <[email protected] >\$" patch5
178
158
'
179
159
180
160
test_expect_failure ' additional command line cc (rfc822)' '
181
-
182
161
git config --replace-all format.headers "Cc: R E Cipient <[email protected] >" &&
183
162
git format-patch --cc="S. E. Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch5 &&
184
163
grep "^Cc: R E Cipient <[email protected] >,\$" patch5 &&
185
164
grep "^ *\"S. E. Cipient\" <[email protected] >\$" patch5
186
165
'
187
166
188
167
test_expect_success ' command line headers' '
189
-
190
168
git config --unset-all format.headers &&
191
169
git format-patch --add-header="Cc: R E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch6 &&
192
170
grep "^Cc: R E Cipient <[email protected] >\$" patch6
193
171
'
194
172
195
173
test_expect_success ' configuration headers and command line headers' '
196
-
197
174
git config --replace-all format.headers "Cc: R E Cipient <[email protected] >" &&
198
175
git format-patch --add-header="Cc: S E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch7 &&
199
176
grep "^Cc: R E Cipient <[email protected] >,\$" patch7 &&
200
177
grep "^ *S E Cipient <[email protected] >\$" patch7
201
178
'
202
179
203
180
test_expect_success ' command line To: header (ascii)' '
204
-
205
181
git config --unset-all format.headers &&
206
182
git format-patch --to="R E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch8 &&
207
183
grep "^To: R E Cipient <[email protected] >\$" patch8
208
184
'
209
185
210
186
test_expect_failure ' command line To: header (rfc822)' '
211
-
212
187
git format-patch --to="R. E. Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch8 &&
213
188
grep "^To: \"R. E. Cipient\" <[email protected] >\$" patch8
214
189
'
215
190
216
191
test_expect_failure ' command line To: header (rfc2047)' '
217
-
218
192
git format-patch --to="R Ä Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch8 &&
219
193
grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected] >\$" patch8
220
194
'
221
195
222
196
test_expect_success ' configuration To: header (ascii)' '
223
-
224
197
git config format.to "R E Cipient <[email protected] >" &&
225
198
git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
226
199
grep "^To: R E Cipient <[email protected] >\$" patch9
227
200
'
228
201
229
202
test_expect_failure ' configuration To: header (rfc822)' '
230
-
231
203
git config format.to "R. E. Cipient <[email protected] >" &&
232
204
git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
233
205
grep "^To: \"R. E. Cipient\" <[email protected] >\$" patch9
234
206
'
235
207
236
208
test_expect_failure ' configuration To: header (rfc2047)' '
237
-
238
209
git config format.to "R Ä Cipient <[email protected] >" &&
239
210
git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
240
211
grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected] >\$" patch9
@@ -249,47 +220,41 @@ check_patch () {
249
220
}
250
221
251
222
test_expect_success ' format.from=false' '
252
-
253
223
git -c format.from=false format-patch --stdout master..side |
254
224
sed -e "/^\$/q" >patch &&
255
225
check_patch patch &&
256
226
! grep "^From: C O Mitter <[email protected] >\$" patch
257
227
'
258
228
259
229
test_expect_success ' format.from=true' '
260
-
261
230
git -c format.from=true format-patch --stdout master..side |
262
231
sed -e "/^\$/q" >patch &&
263
232
check_patch patch &&
264
233
grep "^From: C O Mitter <[email protected] >\$" patch
265
234
'
266
235
267
236
test_expect_success ' format.from with address' '
268
-
269
237
git -c format.from="F R Om <[email protected] >" format-patch --stdout master..side |
270
238
sed -e "/^\$/q" >patch &&
271
239
check_patch patch &&
272
240
grep "^From: F R Om <[email protected] >\$" patch
273
241
'
274
242
275
243
test_expect_success ' --no-from overrides format.from' '
276
-
277
244
git -c format.from="F R Om <[email protected] >" format-patch --no-from --stdout master..side |
278
245
sed -e "/^\$/q" >patch &&
279
246
check_patch patch &&
280
247
! grep "^From: F R Om <[email protected] >\$" patch
281
248
'
282
249
283
250
test_expect_success ' --from overrides format.from' '
284
-
285
251
git -c format.from="F R Om <[email protected] >" format-patch --from --stdout master..side |
286
252
sed -e "/^\$/q" >patch &&
287
253
check_patch patch &&
288
254
! grep "^From: F R Om <[email protected] >\$" patch
289
255
'
290
256
291
257
test_expect_success ' --no-to overrides config.to' '
292
-
293
258
git config --replace-all format.to \
294
259
"R E Cipient <[email protected] >" &&
295
260
git format-patch --no-to --stdout master..side |
@@ -299,7 +264,6 @@ test_expect_success '--no-to overrides config.to' '
299
264
'
300
265
301
266
test_expect_success ' --no-to and --to replaces config.to' '
302
-
303
267
git config --replace-all format.to \
304
268
305
269
git format-patch --no-to --to="Someone Else <[email protected] >" \
@@ -311,7 +275,6 @@ test_expect_success '--no-to and --to replaces config.to' '
311
275
'
312
276
313
277
test_expect_success ' --no-cc overrides config.cc' '
314
-
315
278
git config --replace-all format.cc \
316
279
"C E Cipient <[email protected] >" &&
317
280
git format-patch --no-cc --stdout master..side |
@@ -321,7 +284,6 @@ test_expect_success '--no-cc overrides config.cc' '
321
284
'
322
285
323
286
test_expect_success ' --no-add-header overrides config.headers' '
324
-
325
287
git config --replace-all format.headers \
326
288
"Header1: B E Cipient <[email protected] >" &&
327
289
git format-patch --no-add-header --stdout master..side |
@@ -331,7 +293,6 @@ test_expect_success '--no-add-header overrides config.headers' '
331
293
'
332
294
333
295
test_expect_success ' multiple files' '
334
-
335
296
rm -rf patches/ &&
336
297
git checkout side &&
337
298
git format-patch -o patches/ master &&
@@ -594,7 +555,6 @@ test_expect_success 'thread config + --no-thread' '
594
555
'
595
556
596
557
test_expect_success ' excessive subject' '
597
-
598
558
rm -rf patches/ &&
599
559
git checkout side &&
600
560
before=$(git hash-object file) &&
@@ -622,7 +582,6 @@ test_expect_success 'cover-letter inherits diff options' '
622
582
! grep "file => foo .* 0 *\$" 0000-cover-letter.patch &&
623
583
git format-patch --cover-letter -1 -M &&
624
584
grep "file => foo .* 0 *\$" 0000-cover-letter.patch
625
-
626
585
'
627
586
628
587
cat > expect << EOF
@@ -636,11 +595,9 @@ cat > expect << EOF
636
595
EOF
637
596
638
597
test_expect_success ' shortlog of cover-letter wraps overly-long onelines' '
639
-
640
598
git format-patch --cover-letter -2 &&
641
599
sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output &&
642
600
test_cmp expect output
643
-
644
601
'
645
602
646
603
cat > expect << EOF
@@ -656,13 +613,11 @@ index $before..$after 100644
656
613
EOF
657
614
658
615
test_expect_success ' format-patch respects -U' '
659
-
660
616
git format-patch -U4 -2 &&
661
617
sed -e "1,/^diff/d" -e "/^+5/q" \
662
618
<0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
663
619
>output &&
664
620
test_cmp expect output
665
-
666
621
'
667
622
668
623
cat > expect << EOF
@@ -679,11 +634,9 @@ index $before..$after 100644
679
634
EOF
680
635
681
636
test_expect_success ' format-patch -p suppresses stat' '
682
-
683
637
git format-patch -p -2 &&
684
638
sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
685
639
test_cmp expect output
686
-
687
640
'
688
641
689
642
test_expect_success ' format-patch from a subdirectory (1)' '
0 commit comments