@@ -33,7 +33,8 @@ test_expect_success setup '
33
33
git commit -m "Side changes #3 with \\n backslash-n in it." &&
34
34
35
35
git checkout master &&
36
- git diff-tree -p C2 | git apply --index &&
36
+ git diff-tree -p C2 >patch &&
37
+ git apply --index <patch &&
37
38
test_tick &&
38
39
git commit -m "Master accepts moral equivalent of #2" &&
39
40
@@ -110,7 +111,8 @@ test_expect_success 'format-patch --ignore-if-in-upstream result applies' '
110
111
'
111
112
112
113
test_expect_success ' commit did not screw up the log message' '
113
- git cat-file commit side | grep "^Side .* with .* backslash-n"
114
+ git cat-file commit side >actual &&
115
+ grep "^Side .* with .* backslash-n" actual
114
116
'
115
117
116
118
test_expect_success ' format-patch did not screw up the log message' '
@@ -119,7 +121,8 @@ test_expect_success 'format-patch did not screw up the log message' '
119
121
'
120
122
121
123
test_expect_success ' replay did not screw up the log message' '
122
- git cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"
124
+ git cat-file commit rebuild-1 >actual &&
125
+ grep "^Side .* with .* backslash-n" actual
123
126
'
124
127
125
128
test_expect_success ' extra headers' '
@@ -153,63 +156,73 @@ test_expect_success 'extra headers with multiple To:s' '
153
156
154
157
test_expect_success ' additional command line cc (ascii)' '
155
158
git config --replace-all format.headers "Cc: R E Cipient <[email protected] >" &&
156
- git format-patch --cc="S E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch5 &&
157
- grep "^Cc: R E Cipient <[email protected] >,\$" patch5 &&
158
- grep "^ *S E Cipient <[email protected] >\$" patch5
159
+ git format-patch --cc="S E Cipient <[email protected] >" --stdout master..side >patch5 &&
160
+ sed -e "/^\$/q" patch5 >hdrs5 &&
161
+ grep "^Cc: R E Cipient <[email protected] >,\$" hdrs5 &&
162
+ grep "^ *S E Cipient <[email protected] >\$" hdrs5
159
163
'
160
164
161
165
test_expect_failure ' additional command line cc (rfc822)' '
162
166
git config --replace-all format.headers "Cc: R E Cipient <[email protected] >" &&
163
- git format-patch --cc="S. E. Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch5 &&
164
- grep "^Cc: R E Cipient <[email protected] >,\$" patch5 &&
165
- grep "^ *\"S. E. Cipient\" <[email protected] >\$" patch5
167
+ git format-patch --cc="S. E. Cipient <[email protected] >" --stdout master..side >patch5 &&
168
+ sed -e "/^\$/q" patch5 >hdrs5 &&
169
+ grep "^Cc: R E Cipient <[email protected] >,\$" hdrs5 &&
170
+ grep "^ *\"S. E. Cipient\" <[email protected] >\$" hdrs5
166
171
'
167
172
168
173
test_expect_success ' command line headers' '
169
174
git config --unset-all format.headers &&
170
- git format-patch --add-header="Cc: R E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch6 &&
171
- grep "^Cc: R E Cipient <[email protected] >\$" patch6
175
+ git format-patch --add-header="Cc: R E Cipient <[email protected] >" --stdout master..side >patch6 &&
176
+ sed -e "/^\$/q" patch6 >hdrs6 &&
177
+ grep "^Cc: R E Cipient <[email protected] >\$" hdrs6
172
178
'
173
179
174
180
test_expect_success ' configuration headers and command line headers' '
175
181
git config --replace-all format.headers "Cc: R E Cipient <[email protected] >" &&
176
- git format-patch --add-header="Cc: S E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch7 &&
177
- grep "^Cc: R E Cipient <[email protected] >,\$" patch7 &&
178
- grep "^ *S E Cipient <[email protected] >\$" patch7
182
+ git format-patch --add-header="Cc: S E Cipient <[email protected] >" --stdout master..side >patch7 &&
183
+ sed -e "/^\$/q" patch7 >hdrs7 &&
184
+ grep "^Cc: R E Cipient <[email protected] >,\$" hdrs7 &&
185
+ grep "^ *S E Cipient <[email protected] >\$" hdrs7
179
186
'
180
187
181
188
test_expect_success ' command line To: header (ascii)' '
182
189
git config --unset-all format.headers &&
183
- git format-patch --to="R E Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch8 &&
184
- grep "^To: R E Cipient <[email protected] >\$" patch8
190
+ git format-patch --to="R E Cipient <[email protected] >" --stdout master..side >patch8 &&
191
+ sed -e "/^\$/q" patch8 >hdrs8 &&
192
+ grep "^To: R E Cipient <[email protected] >\$" hdrs8
185
193
'
186
194
187
195
test_expect_failure ' command line To: header (rfc822)' '
188
- git format-patch --to="R. E. Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch8 &&
189
- grep "^To: \"R. E. Cipient\" <[email protected] >\$" patch8
196
+ git format-patch --to="R. E. Cipient <[email protected] >" --stdout master..side >patch8 &&
197
+ sed -e "/^\$/q" patch8 >hdrs8 &&
198
+ grep "^To: \"R. E. Cipient\" <[email protected] >\$" hdrs8
190
199
'
191
200
192
201
test_expect_failure ' command line To: header (rfc2047)' '
193
- git format-patch --to="R Ä Cipient <[email protected] >" --stdout master..side | sed -e "/^\$/q" >patch8 &&
194
- grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected] >\$" patch8
202
+ git format-patch --to="R Ä Cipient <[email protected] >" --stdout master..side >patch8 &&
203
+ sed -e "/^\$/q" patch8 >hdrs8 &&
204
+ grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected] >\$" hdrs8
195
205
'
196
206
197
207
test_expect_success ' configuration To: header (ascii)' '
198
208
git config format.to "R E Cipient <[email protected] >" &&
199
- git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
200
- grep "^To: R E Cipient <[email protected] >\$" patch9
209
+ git format-patch --stdout master..side >patch9 &&
210
+ sed -e "/^\$/q" patch9 >hdrs9 &&
211
+ grep "^To: R E Cipient <[email protected] >\$" hdrs9
201
212
'
202
213
203
214
test_expect_failure ' configuration To: header (rfc822)' '
204
215
git config format.to "R. E. Cipient <[email protected] >" &&
205
- git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
206
- grep "^To: \"R. E. Cipient\" <[email protected] >\$" patch9
216
+ git format-patch --stdout master..side >patch9 &&
217
+ sed -e "/^\$/q" patch9 >hdrs9 &&
218
+ grep "^To: \"R. E. Cipient\" <[email protected] >\$" hdrs9
207
219
'
208
220
209
221
test_expect_failure ' configuration To: header (rfc2047)' '
210
222
git config format.to "R Ä Cipient <[email protected] >" &&
211
- git format-patch --stdout master..side | sed -e "/^\$/q" >patch9 &&
212
- grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected] >\$" patch9
223
+ git format-patch --stdout master..side >patch9 &&
224
+ sed -e "/^\$/q" patch9 >hdrs9 &&
225
+ grep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <[email protected] >\$" hdrs9
213
226
'
214
227
215
228
# check_patch <patch>: Verify that <patch> looks like a half-sane
@@ -221,76 +234,76 @@ check_patch () {
221
234
}
222
235
223
236
test_expect_success ' format.from=false' '
224
- git -c format.from=false format-patch --stdout master..side |
225
- sed -e "/^\$/q" > patch &&
237
+ git -c format.from=false format-patch --stdout master..side >patch &&
238
+ sed -e "/^\$/q" patch >hdrs &&
226
239
check_patch patch &&
227
- ! grep "^From: C O Mitter <[email protected] >\$" patch
240
+ ! grep "^From: C O Mitter <[email protected] >\$" hdrs
228
241
'
229
242
230
243
test_expect_success ' format.from=true' '
231
- git -c format.from=true format-patch --stdout master..side |
232
- sed -e "/^\$/q" > patch &&
233
- check_patch patch &&
234
- grep "^From: C O Mitter <[email protected] >\$" patch
244
+ git -c format.from=true format-patch --stdout master..side >patch &&
245
+ sed -e "/^\$/q" patch >hdrs &&
246
+ check_patch hdrs &&
247
+ grep "^From: C O Mitter <[email protected] >\$" hdrs
235
248
'
236
249
237
250
test_expect_success ' format.from with address' '
238
- git -c format.from="F R Om <[email protected] >" format-patch --stdout master..side |
239
- sed -e "/^\$/q" > patch &&
240
- check_patch patch &&
241
- grep "^From: F R Om <[email protected] >\$" patch
251
+ git -c format.from="F R Om <[email protected] >" format-patch --stdout master..side >patch &&
252
+ sed -e "/^\$/q" patch >hdrs &&
253
+ check_patch hdrs &&
254
+ grep "^From: F R Om <[email protected] >\$" hdrs
242
255
'
243
256
244
257
test_expect_success ' --no-from overrides format.from' '
245
- git -c format.from="F R Om <[email protected] >" format-patch --no-from --stdout master..side |
246
- sed -e "/^\$/q" > patch &&
247
- check_patch patch &&
248
- ! grep "^From: F R Om <[email protected] >\$" patch
258
+ git -c format.from="F R Om <[email protected] >" format-patch --no-from --stdout master..side >patch &&
259
+ sed -e "/^\$/q" patch >hdrs &&
260
+ check_patch hdrs &&
261
+ ! grep "^From: F R Om <[email protected] >\$" hdrs
249
262
'
250
263
251
264
test_expect_success ' --from overrides format.from' '
252
- git -c format.from="F R Om <[email protected] >" format-patch --from --stdout master..side |
253
- sed -e "/^\$/q" > patch &&
254
- check_patch patch &&
255
- ! grep "^From: F R Om <[email protected] >\$" patch
265
+ git -c format.from="F R Om <[email protected] >" format-patch --from --stdout master..side >patch &&
266
+ sed -e "/^\$/q" patch >hdrs &&
267
+ check_patch hdrs &&
268
+ ! grep "^From: F R Om <[email protected] >\$" hdrs
256
269
'
257
270
258
271
test_expect_success ' --no-to overrides config.to' '
259
272
git config --replace-all format.to \
260
273
"R E Cipient <[email protected] >" &&
261
- git format-patch --no-to --stdout master..side |
262
- sed -e "/^\$/q" > patch10 &&
263
- check_patch patch10 &&
264
- ! grep "^To: R E Cipient <[email protected] >\$" patch10
274
+ git format-patch --no-to --stdout master..side >patch10 &&
275
+ sed -e "/^\$/q" patch10 >hdrs10 &&
276
+ check_patch hdrs10 &&
277
+ ! grep "^To: R E Cipient <[email protected] >\$" hdrs10
265
278
'
266
279
267
280
test_expect_success ' --no-to and --to replaces config.to' '
268
281
git config --replace-all format.to \
269
282
270
283
git format-patch --no-to --to="Someone Else <[email protected] >" \
271
- --stdout master..side |
272
- sed -e "/^\$/q" > patch11 &&
273
- check_patch patch11 &&
274
- ! grep "^To: Someone <[email protected] >\$" patch11 &&
275
- grep "^To: Someone Else <[email protected] >\$" patch11
284
+ --stdout master..side >patch11 &&
285
+ sed -e "/^\$/q" patch11 >hdrs11 &&
286
+ check_patch hdrs11 &&
287
+ ! grep "^To: Someone <[email protected] >\$" hdrs11 &&
288
+ grep "^To: Someone Else <[email protected] >\$" hdrs11
276
289
'
277
290
278
291
test_expect_success ' --no-cc overrides config.cc' '
279
292
git config --replace-all format.cc \
280
293
"C E Cipient <[email protected] >" &&
281
- git format-patch --no-cc --stdout master..side |
282
- sed -e "/^\$/q" > patch12 &&
283
- check_patch patch12 &&
284
- ! grep "^Cc: C E Cipient <[email protected] >\$" patch12
294
+ git format-patch --no-cc --stdout master..side >patch12 &&
295
+ sed -e "/^\$/q" patch12 >hdrs12 &&
296
+ check_patch hdrs12 &&
297
+ ! grep "^Cc: C E Cipient <[email protected] >\$" hdrs12
285
298
'
286
299
287
300
test_expect_success ' --no-add-header overrides config.headers' '
288
301
git config --replace-all format.headers \
289
302
"Header1: B E Cipient <[email protected] >" &&
290
- git format-patch --no-add-header --stdout master..side |
291
- sed -e "/^\$/q" > patch13 &&
292
- check_patch patch13 &&
293
- ! grep "^Header1: B E Cipient <[email protected] >\$" patch13
303
+ git format-patch --no-add-header --stdout master..side >patch13 &&
304
+ sed -e "/^\$/q" patch13 >hdrs13 &&
305
+ check_patch hdrs13 &&
306
+ ! grep "^Header1: B E Cipient <[email protected] >\$" hdrs13
294
307
'
295
308
296
309
test_expect_success ' multiple files' '
@@ -808,20 +821,25 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
808
821
git format-patch --ignore-if-in-upstream HEAD
809
822
'
810
823
811
- git_version=" $( git --version | sed " s/.* //" ) "
824
+ test_expect_success ' get git version' '
825
+ git_version=$(git --version) &&
826
+ git_version=${git_version##* }
827
+ '
812
828
813
829
signature () {
814
830
printf " %s\n%s\n\n" " -- " " ${1:- $git_version } "
815
831
}
816
832
817
833
test_expect_success ' format-patch default signature' '
818
- git format-patch --stdout -1 | tail -n 3 >output &&
834
+ git format-patch --stdout -1 >patch &&
835
+ tail -n 3 patch >output &&
819
836
signature >expect &&
820
837
test_cmp expect output
821
838
'
822
839
823
840
test_expect_success ' format-patch --signature' '
824
- git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
841
+ git format-patch --stdout --signature="my sig" -1 >patch &&
842
+ tail -n 3 patch >output &&
825
843
signature "my sig" >expect &&
826
844
test_cmp expect output
827
845
'
@@ -1606,19 +1624,40 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
1606
1624
1607
1625
test_expect_success ' format-patch --base' '
1608
1626
git checkout patchid &&
1609
- git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&
1610
- git format-patch --stdout --base=HEAD~3 HEAD~.. | tail -n 7 >actual2 &&
1627
+
1628
+ git format-patch --stdout --base=HEAD~3 -1 >patch &&
1629
+ tail -n 7 patch >actual1 &&
1630
+
1631
+ git format-patch --stdout --base=HEAD~3 HEAD~.. >patch &&
1632
+ tail -n 7 patch >actual2 &&
1633
+
1611
1634
echo >expect &&
1612
- echo "base-commit: $(git rev-parse HEAD~3)" >>expect &&
1613
- echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expect &&
1614
- echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expect &&
1635
+ git rev-parse HEAD~3 >commit-id-base &&
1636
+ echo "base-commit: $(cat commit-id-base)" >>expect &&
1637
+
1638
+ git show --patch HEAD~2 >patch &&
1639
+ git patch-id --stable <patch >patch.id.raw &&
1640
+ awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
1641
+
1642
+ git show --patch HEAD~1 >patch &&
1643
+ git patch-id --stable <patch >patch.id.raw &&
1644
+ awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>expect &&
1645
+
1615
1646
signature >>expect &&
1616
1647
test_cmp expect actual1 &&
1617
1648
test_cmp expect actual2 &&
1649
+
1618
1650
echo >fail &&
1619
- echo "base-commit: $(git rev-parse HEAD~3)" >>fail &&
1620
- echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
1621
- echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --unstable | awk "{print \$1}")" >>fail &&
1651
+ echo "base-commit: $(cat commit-id-base)" >>fail &&
1652
+
1653
+ git show --patch HEAD~2 >patch &&
1654
+ git patch-id --unstable <patch >patch.id.raw &&
1655
+ awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
1656
+
1657
+ git show --patch HEAD~1 >patch &&
1658
+ git patch-id --unstable <patch >patch.id.raw &&
1659
+ awk "{print \"prerequisite-patch-id:\", \$1}" <patch.id.raw >>fail &&
1660
+
1622
1661
signature >>fail &&
1623
1662
! test_cmp fail actual1 &&
1624
1663
! test_cmp fail actual2
@@ -1629,7 +1668,8 @@ test_expect_success 'format-patch --base errors out when base commit is in revis
1629
1668
test_must_fail git format-patch --base=HEAD~1 -2 &&
1630
1669
git format-patch --stdout --base=HEAD~2 -2 >patch &&
1631
1670
grep "^base-commit:" patch >actual &&
1632
- echo "base-commit: $(git rev-parse HEAD~2)" >expect &&
1671
+ git rev-parse HEAD~2 >commit-id-base &&
1672
+ echo "base-commit: $(cat commit-id-base)" >expect &&
1633
1673
test_cmp expect actual
1634
1674
'
1635
1675
@@ -1668,7 +1708,8 @@ test_expect_success 'format-patch --base=auto' '
1668
1708
test_commit N2 &&
1669
1709
git format-patch --stdout --base=auto -2 >patch &&
1670
1710
grep "^base-commit:" patch >actual &&
1671
- echo "base-commit: $(git rev-parse upstream)" >expect &&
1711
+ git rev-parse upstream >commit-id-base &&
1712
+ echo "base-commit: $(cat commit-id-base)" >expect &&
1672
1713
test_cmp expect actual
1673
1714
'
1674
1715
@@ -1705,7 +1746,8 @@ test_expect_success 'format-patch format.useAutoBaseoption' '
1705
1746
git config format.useAutoBase true &&
1706
1747
git format-patch --stdout -1 >patch &&
1707
1748
grep "^base-commit:" patch >actual &&
1708
- echo "base-commit: $(git rev-parse upstream)" >expect &&
1749
+ git rev-parse upstream >commit-id-base &&
1750
+ echo "base-commit: $(cat commit-id-base)" >expect &&
1709
1751
test_cmp expect actual
1710
1752
'
1711
1753
@@ -1714,7 +1756,8 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
1714
1756
git config format.useAutoBase true &&
1715
1757
git format-patch --stdout --base=HEAD~1 -1 >patch &&
1716
1758
grep "^base-commit:" patch >actual &&
1717
- echo "base-commit: $(git rev-parse HEAD~1)" >expect &&
1759
+ git rev-parse HEAD~1 >commit-id-base &&
1760
+ echo "base-commit: $(cat commit-id-base)" >expect &&
1718
1761
test_cmp expect actual
1719
1762
'
1720
1763
0 commit comments