{"thread":{"id":"3584","subject":"PATCH: Allow format-patch to attach patches","startedAt":"2006-03-06T13:12:12Z","lastAt":"2006-03-07T03:24:39Z","messageCount":4,"participants":["Mike McCormack","Junio C Hamano","A Large Angry SCM"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"17257","messageId":"440C352C.9070009@codeweavers.com","threadId":"3584","inReplyTo":null,"subject":"PATCH: Allow format-patch to attach patches","fromName":"Mike McCormack","fromEmail":"mike@codeweavers.com","sentAt":"2006-03-06T13:12:12Z","receivedAt":"2006-03-06T13:12:12Z","isPatch":false,"sender":{"key":"mike@codeweavers.com","avatar":null},"body":"\nThe --attach patch to git-format-patch to attach patches instead of \ninlining them.  Some mailers linewrap inlined patches (eg. Mozilla).\n\n---\n\n  git-format-patch.sh |   52 \n++++++++++++++++++++++++++++++++++++++++++++-------\n  1 files changed, 45 insertions(+), 7 deletions(-)\n\n\n\nb17ef6b06ebaaf9b6d1f47c6a788cffd77e2b927\ndiff --git a/git-format-patch.sh b/git-format-patch.sh\nindex bbd2e55..2ebf7e8 100755\n--- a/git-format-patch.sh\n+++ b/git-format-patch.sh\n@@ -3,7 +3,7 @@\n # Copyright (c) 2005 Junio C Hamano\n #\n \n-USAGE='[-n | -k] [-o <dir> | --stdout] [--signoff] [--check] [--diff-options] <his> [<mine>]'\n+USAGE='[-n | -k] [-o <dir> | --stdout] [--signoff] [--check] [--diff-options] [--attach] <his> [<mine>]'\n LONG_USAGE='Prepare each commit with its patch since <mine> head forked from\n <his> head, one file per patch formatted to resemble UNIX mailbox\n format, for e-mail submission or use with git-am.\n@@ -18,7 +18,9 @@ is ignored if --stdout is specified.\n \n When -n is specified, instead of \"[PATCH] Subject\", the first\n line is formatted as \"[PATCH N/M] Subject\", unless you have only\n-one patch.'\n+one patch.\n+\n+When --attach is specified, patches are attached, not inlined.'\n \n . git-sh-setup\n \n@@ -40,6 +42,8 @@ do\n     -d|--d|--da|--dat|--date|\\\n     -m|--m|--mb|--mbo|--mbox) # now noop\n     ;;\n+    --at|--att|--atta|--attac|--attach)\n+    attach=t ;;\n     -k|--k|--ke|--kee|--keep|--keep-|--keep-s|--keep-su|--keep-sub|\\\n     --keep-subj|--keep-subje|--keep-subjec|--keep-subject)\n     keep_subject=t ;;\n@@ -150,6 +154,11 @@ done >$series\n \n me=`git-var GIT_AUTHOR_IDENT | sed -e 's/>.*/>/'`\n headers=`git-repo-config --get format.headers`\n+case \"$attach\" in\n+\"\") ;;\n+*)\n+\tmimemagic=\"050802040500080604070107\"\n+esac\n \n case \"$outdir\" in\n */) ;;\n@@ -174,7 +183,7 @@ titleScript='\n \n process_one () {\n \tperl -w -e '\n-my ($keep_subject, $num, $signoff, $headers, $commsg) = @ARGV;\n+my ($keep_subject, $num, $signoff, $headers, $mimemagic, $commsg) = @ARGV;\n my ($signoff_pattern, $done_header, $done_subject, $done_separator, $signoff_seen,\n     $last_was_signoff);\n \n@@ -229,6 +238,16 @@ while (<FH>) {\n \t    print \"$headers\\n\";\n \t}\n         print \"Subject: $_\";\n+\tif ($mimemagic) {\n+\t    print \"MIME-Version: 1.0\\n\";\n+\t    print \"Content-Type: multipart/mixed;\\n\";\n+\t    print \" boundary=\\\"------------$mimemagic\\\"\\n\";\n+\t    print \"\\n\";\n+\t    print \"This is a multi-part message in MIME format.\\n\";\n+\t    print \"--------------$mimemagic\\n\";\n+\t    print \"Content-Type: text/plain; charset=UTF-8; format=fixed\\n\";\n+\t    print \"Content-Transfer-Encoding: 8bit\\n\";\n+\t}\n \t$done_subject = 1;\n \tnext;\n     }\n@@ -254,14 +273,33 @@ if (!$signoff_seen && $signoff ne \"\") {\n }\n print \"\\n---\\n\\n\";\n close FH or die \"close $commsg pipe\";\n-' \"$keep_subject\" \"$num\" \"$signoff\" \"$headers\" $commsg\n+' \"$keep_subject\" \"$num\" \"$signoff\" \"$headers\" \"$mimemagic\" $commsg\n \n \tgit-diff-tree -p $diff_opts \"$commit\" | git-apply --stat --summary\n \techo\n+\tcase \"$mimemagic\" in\n+\t'');;\n+\t*)\n+\t\techo \"--------------$mimemagic\"\n+\t\techo \"Content-Type: text/x-patch;\"\n+\t\techo \" name=\\\"$commit.diff\\\"\"\n+\t\techo \"Content-Transfer-Encoding: 8bit\"\n+\t\techo \"Content-Disposition: inline;\"\n+\t\techo \" filename=\\\"$commit.diff\\\"\"\n+\t\techo\n+\tesac\n \tgit-diff-tree -p $diff_opts \"$commit\"\n-\techo \"-- \"\n-\techo \"@@GIT_VERSION@@\"\n-\n+\tcase \"$mimemagic\" in\n+\t'')\n+\t\techo \"-- \"\n+\t\techo \"@@GIT_VERSION@@\"\n+\t\t;;\n+\t*)\n+\t\techo\n+\t\techo \"--------------$mimemagic--\"\n+\t\techo\n+\t\t;;\n+\tesac\n \techo\n }\n \n\n"},{"id":"17272","messageId":"7vpskz5aqh.fsf@assigned-by-dhcp.cox.net","threadId":"3584","inReplyTo":"440C352C.9070009@codeweavers.com","subject":"Re: PATCH: Allow format-patch to attach patches","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-07T01:01:26Z","receivedAt":"2006-03-07T01:01:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nicely done.\n\nEspecially I like the part that you explicitly set charset to\nUTF-8 to the primary part.\n\nThe only two and half minor issues I might have about this are:\n\n (1) is the type text/x-patch appropriate?\n\n (2) is it possible to cheaply come up with a safe mime-magic,\n     instead of a hardcoded long string and hope it does not\n     clash?\n\nYou can just say \"Yes it is an established practice, widely\naccepted and that is what you are responding to so obviously you\ncan grok it ;-)\" to (1).  About (2), you would probably need to\nread the \"diff-tree -p\" output beforehand if we want to be\nabsolutely sure, so punting on the issue like this might be the\nbest practical approach for now, but I am asking it anyway\nbecause people may have better ideas.\n\nThe remaining half issue is if would it make sense to sometimes\noptionally use non 8-bit CTE for the patch part.  I do _NOT_\nwant to receive CTE=QP patch myself, nor I want to encourage it\n(actually I would want to actively discourage it), but I do not\nmind if people find use of such a patch in a distant corner of\nthe galaxy where I do not have to touch such a patch.\n"},{"id":"17278","messageId":"440CFC06.9080901@codeweavers.com","threadId":"3584","inReplyTo":"7vpskz5aqh.fsf@assigned-by-dhcp.cox.net","subject":"Re: PATCH: Allow format-patch to attach patches","fromName":"Mike McCormack","fromEmail":"mike@codeweavers.com","sentAt":"2006-03-07T03:20:38Z","receivedAt":"2006-03-07T03:20:38Z","isPatch":false,"sender":{"key":"mike@codeweavers.com","avatar":null},"body":"\nJunio C Hamano wrote:\n\n> The only two and half minor issues I might have about this are:\n> \n>  (1) is the type text/x-patch appropriate?\n\nI'm no expert on MIME types, unfortunately.  Maybe text/x-diff makes \nmore sense?   A few different projects require one of those two types \nfor diffs sent as attachments.  My main concern is that mailers can \nrecognize that the attachment is text, then displayed with the message \nso that people can see the patch without opening the attachment.\n\n>  (2) is it possible to cheaply come up with a safe mime-magic,\n>      instead of a hardcoded long string and hope it does not\n>      clash?\n\nI agree that using a hardcoded long string isn't that great.  Reading \nall of the \"diff-tree -p\" output seems a bit expensive.  How about using \n   some part of the patch's SHA1 combined with date/time?\n\n> The remaining half issue is if would it make sense to sometimes\n> optionally use non 8-bit CTE for the patch part.\n\nMaybe allow something like:\n\ngit-format-patch --attach=quoted-printable\n\nwhere the default would be 8bit.  This require adding a perl script for \neach Content-Transfer-Encoding that we support.\n\nMike\n"},{"id":"17277","messageId":"440CFCF7.9090407@gmail.com","threadId":"3584","inReplyTo":"7vpskz5aqh.fsf@assigned-by-dhcp.cox.net","subject":"Re: PATCH: Allow format-patch to attach patches","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2006-03-07T03:24:39Z","receivedAt":"2006-03-07T03:24:39Z","isPatch":false,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Nicely done.\n...\n> The only two and half minor issues I might have about this are:\n> \n...\n> \n>  (2) is it possible to cheaply come up with a safe mime-magic,\n>      instead of a hardcoded long string and hope it does not\n>      clash?\n\nBase64 encode a large number (160?) of bits from /dev/urandom.\n"}]}