Allow format-patch to attach patches
The --attach patch to git-format-patch to attach patches instead of inlining them. Some mailers linewrap inlined patches (eg. Mozilla). Signed-off-by: Junio C Hamano <junkio@cox.net>
Mike McCormack committed
Mar 6, 2006 at 22:12 UTC
19bb732728e0e58790b7045250ed47d4831fade5
1 file changed
+45
-7
git-format-patch.sh
+45
-7
@@ -3,7 +3,7 @@
3
# Copyright (c) 2005 Junio C Hamano
4
#
5
6
-USAGE='[-n | -k] [-o <dir> | --stdout] [--signoff] [--check] [--diff-options] <his> [<mine>]'
6
+USAGE='[-n | -k] [-o <dir> | --stdout] [--signoff] [--check] [--diff-options] [--attach] <his> [<mine>]'
7
LONG_USAGE='Prepare each commit with its patch since <mine> head forked from
8
<his> head, one file per patch formatted to resemble UNIX mailbox
9
format, for e-mail submission or use with git-am.
@@ -18,7 +18,9 @@ is ignored if --stdout is specified.
18
19
When -n is specified, instead of "[PATCH] Subject", the first
20
line is formatted as "[PATCH N/M] Subject", unless you have only
21
-one patch.'
21
+one patch.
22
+
23
+When --attach is specified, patches are attached, not inlined.'
24
25
. git-sh-setup
26
@@ -40,6 +42,8 @@ do
42
-d|--d|--da|--dat|--date|\
43
-m|--m|--mb|--mbo|--mbox) # now noop
44
;;
45
+ --at|--att|--atta|--attac|--attach)
46
+ attach=t ;;
47
-k|--k|--ke|--kee|--keep|--keep-|--keep-s|--keep-su|--keep-sub|\
48
--keep-subj|--keep-subje|--keep-subjec|--keep-subject)
49
keep_subject=t ;;
@@ -150,6 +154,11 @@ done >$series
154
155
me=`git-var GIT_AUTHOR_IDENT | sed -e 's/>.*/>/'`
156
headers=`git-repo-config --get format.headers`
157
+case "$attach" in
158
+"") ;;
159
+*)
160
+ mimemagic="050802040500080604070107"
161
+esac
162
163
case "$outdir" in
164
*/) ;;
@@ -174,7 +183,7 @@ titleScript='
183
184
process_one () {
185
perl -w -e '
177
-my ($keep_subject, $num, $signoff, $headers, $commsg) = @ARGV;
186
+my ($keep_subject, $num, $signoff, $headers, $mimemagic, $commsg) = @ARGV;
187
my ($signoff_pattern, $done_header, $done_subject, $done_separator, $signoff_seen,
188
$last_was_signoff);
189
@@ -229,6 +238,16 @@ while (<FH>) {
238
print "$headers\n";
239
}
240
print "Subject: $_";
241
+ if ($mimemagic) {
242
+ print "MIME-Version: 1.0\n";
243
+ print "Content-Type: multipart/mixed;\n";
244
+ print " boundary=\"------------$mimemagic\"\n";
245
+ print "\n";
246
+ print "This is a multi-part message in MIME format.\n";
247
+ print "--------------$mimemagic\n";
248
+ print "Content-Type: text/plain; charset=UTF-8; format=fixed\n";
249
+ print "Content-Transfer-Encoding: 8bit\n";
250
+ }
251
$done_subject = 1;
252
next;
253
}
@@ -254,14 +273,33 @@ if (!$signoff_seen && $signoff ne "") {
273
}
274
print "\n---\n\n";
275
close FH or die "close $commsg pipe";
257
-' "$keep_subject" "$num" "$signoff" "$headers" $commsg
276
+' "$keep_subject" "$num" "$signoff" "$headers" "$mimemagic" $commsg
277
278
git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary
279
echo
280
+ case "$mimemagic" in
281
+ '');;
282
+ *)
283
+ echo "--------------$mimemagic"
284
+ echo "Content-Type: text/x-patch;"
285
+ echo " name=\"$commit.diff\""
286
+ echo "Content-Transfer-Encoding: 8bit"
287
+ echo "Content-Disposition: inline;"
288
+ echo " filename=\"$commit.diff\""
289
+ echo
290
+ esac
291
git-diff-tree -p $diff_opts "$commit"
262
- echo "-- "
263
- echo "@@GIT_VERSION@@"
264
-
292
+ case "$mimemagic" in
293
+ '')
294
+ echo "-- "
295
+ echo "@@GIT_VERSION@@"
296
+ ;;
297
+ *)
298
+ echo
299
+ echo "--------------$mimemagic--"
300
+ echo
301
+ ;;
302
+ esac
303
echo
304
}
305