{"thread":{"id":"2828","subject":"[PATCH] git-am --one","startedAt":"2005-12-14T01:10:29Z","lastAt":"2005-12-14T02:06:07Z","messageCount":6,"participants":["H. Peter Anvin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13598","messageId":"439F7105.9050302@zytor.com","threadId":"2828","inReplyTo":null,"subject":"[PATCH] git-am --one","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-12-14T01:10:29Z","receivedAt":"2005-12-14T01:10:29Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"This patch adds the --one (-o) option to git-am, to apply a single \nmessage in RFC 2822 format, as opposed to an mbox.  With some MUAs it's \na lot easier to save individual messages than with mboxes, and either \nway the user may want to control the ordering if there are known \ninterdependencies.\n\nSigned-off-by: H. Peter Anvin <hpa@zytor.com>\n\n\ndiff --git a/Documentation/git-am.txt b/Documentation/git-am.txt\nindex a415fe2..bec5c84 100644\n--- a/Documentation/git-am.txt\n+++ b/Documentation/git-am.txt\n@@ -8,7 +8,7 @@ git-am - Apply a series of patches in a \n \n SYNOPSIS\n --------\n-'git-am' [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>...\n+'git-am' [--one] [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>...\n 'git-am' [--skip | --resolved]\n \n DESCRIPTION\n@@ -19,6 +19,10 @@ current branch.\n \n OPTIONS\n -------\n+--one::\n+\tIndicates that <mbox> contains a single message in RFC 2822\n+\tformat, without mbox-style separators.\n+\n --signoff::\n \tAdd `Signed-off-by:` line to the commit message, using\n \tthe committer identity of yourself.\ndiff --git a/git-am.sh b/git-am.sh\nindex 6ed527c..9628651 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -4,7 +4,7 @@\n . git-sh-setup\n \n usage () {\n-    echo >&2 \"usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>\"\n+    echo >&2 \"usage: $0 [--one] [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>\"\n     echo >&2 \"\tor, when resuming\"\n     echo >&2 \"\t$0 [--skip | --resolved]\"\n     exit 1;\n@@ -98,11 +98,13 @@ fall_back_3way () {\n }\n \n prec=4\n-dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary=\n+dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= one=\n \n while case \"$#\" in 0) break;; esac\n do\n \tcase \"$1\" in\n+\t-o|--o|--on|--one)\n+\tone=t; shift;;\n \t-d=*|--d=*|--do=*|--dot=*|--dote=*|--dotes=*|--dotest=*)\n \tdotest=`expr \"$1\" : '-[^=]*=\\(.*\\)'`; shift ;;\n \t-d|--d|--do|--dot|--dote|--dotes|--dotest)\n@@ -165,8 +167,16 @@ else\n \tmkdir -p \"$dotest\" || exit\n \n \t# cat does the right thing for us, including '-' to mean\n-\t# standard input.\n-\tcat \"$@\" |\n+\t# standard input.  To prepend the header, we thus want a\n+\t# second cat, sigh...\n+\tif test \"$one\" = t\n+\tthen\n+\t\tLANG=C date +'From - %a %b %d %T %Y' > \"$dotest\"/fakefrom\n+\t\tfakefrom=\"$dotest\"/fakefrom\n+\telse\n+\t\tfakefrom=/dev/null\n+\tfi\n+\tcat \"$@\" | cat \"$fakefrom\" - |\n \tgit-mailsplit -d$prec \"$dotest/\" >\"$dotest/last\" || {\n \t\trm -fr \"$dotest\"\n \t\texit 1\n"},{"id":"13599","messageId":"7vy82o5uss.fsf@assigned-by-dhcp.cox.net","threadId":"2828","inReplyTo":"439F7105.9050302@zytor.com","subject":"Re: [PATCH] git-am --one","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-14T01:30:59Z","receivedAt":"2005-12-14T01:30:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> This patch adds the --one (-o) option to git-am, to apply a single \n> message in RFC 2822 format, as opposed to an mbox.  With some MUAs it's \n> a lot easier to save individual messages than with mboxes, and either \n> way the user may want to control the ordering if there are known \n> interdependencies.\n\n> +\t# standard input.  To prepend the header, we thus want a\n> +\t# second cat, sigh...\n> +\tif test \"$one\" = t\n> +\tthen\n> +\t\tLANG=C date +'From - %a %b %d %T %Y' > \"$dotest\"/fakefrom\n> +\t\tfakefrom=\"$dotest\"/fakefrom\n> +\telse\n> +\t\tfakefrom=/dev/null\n> +\tfi\n> +\tcat \"$@\" | cat \"$fakefrom\" - |\n>  \tgit-mailsplit -d$prec \"$dotest/\" >\"$dotest/last\" || {\n>  \t\trm -fr \"$dotest\"\n>  \t\texit 1\n\nI understand the motivation, but I suspect skipping mailsplit\nmight be simpler, like this untested code perhaps?\n\n\tcase \"$one\" in\n        '')\n        \t... original code ...\n\t\t;;\n        *)\n\t\tone=`printf \"%${prec}d\" 1`\n        \tcat \"$@\" >\"$dotest/$one\"\n                echo \"$one\" >\"$dotest/last\"\n                ;;\n\tesac\n"},{"id":"13601","messageId":"439F79B3.6000309@zytor.com","threadId":"2828","inReplyTo":"7vy82o5uss.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-am --one","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-12-14T01:47:31Z","receivedAt":"2005-12-14T01:47:31Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Junio C Hamano wrote:\n> \n> I understand the motivation, but I suspect skipping mailsplit\n> might be simpler, like this untested code perhaps?\n> \n> \tcase \"$one\" in\n>         '')\n>         \t... original code ...\n> \t\t;;\n>         *)\n> \t\tone=`printf \"%${prec}d\" 1`\n>         \tcat \"$@\" >\"$dotest/$one\"\n>                 echo \"$one\" >\"$dotest/last\"\n>                 ;;\n> \tesac\n> \n\nIf that works, great.  I just implemented it in the \"most obviously \ncorrect\" way, meaning with as few changes as possible.\n\n\t-hpa\n"},{"id":"13603","messageId":"7v7ja85tqe.fsf@assigned-by-dhcp.cox.net","threadId":"2828","inReplyTo":"439F79B3.6000309@zytor.com","subject":"Re: [PATCH] git-am --one","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-14T01:54:01Z","receivedAt":"2005-12-14T01:54:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> Junio C Hamano wrote:\n>> I understand the motivation, but I suspect skipping mailsplit\n>> might be simpler, like this untested code perhaps?\n>> \tcase \"$one\" in\n>>         '')\n>>         \t... original code ...\n>> \t\t;;\n>>         *)\n>> \t\tone=`printf \"%${prec}d\" 1`\n>>         \tcat \"$@\" >\"$dotest/$one\"\n>>                 echo \"$one\" >\"$dotest/last\"\n>>                 ;;\n>> \tesac\n>>\n>\n> If that works, great.  I just implemented it in the \"most obviously \n> correct\" way, meaning with as few changes as possible.\n\nAnother thing you may probably want is to loop over \"$@\", so\nthat the flag is not --one anymore, but --2822 (or --bare as\nopposed to mbox format) and do something like this:\n\n\tcase \"$series_of_2822_messages\" in\n        '') ... original code ... ;;\n        *)\n        \ti=1\n                for input\n                do\n\t\t\tthis=`printf \"%${prec}d\" $i\n                        cp \"$input\" \"$dotest/$this\"\n                        i=$(($i+1))\n\t\tdone\n                printf \"%${prec}d\" $# >\"$dotest/last\"\n                ;;\n\tesac\n"},{"id":"13604","messageId":"439F7C5A.4030509@zytor.com","threadId":"2828","inReplyTo":"7v7ja85tqe.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-am --one","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-12-14T01:58:50Z","receivedAt":"2005-12-14T01:58:50Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Junio C Hamano wrote:\n> \n> Another thing you may probably want is to loop over \"$@\", so\n> that the flag is not --one anymore, but --2822 (or --bare as\n> opposed to mbox format) and do something like this:\n> \n> \tcase \"$series_of_2822_messages\" in\n>         '') ... original code ... ;;\n>         *)\n>         \ti=1\n>                 for input\n>                 do\n> \t\t\tthis=`printf \"%${prec}d\" $i\n>                         cp \"$input\" \"$dotest/$this\"\n>                         i=$(($i+1))\n> \t\tdone\n>                 printf \"%${prec}d\" $# >\"$dotest/last\"\n>                 ;;\n> \tesac\n> \n\nThat is definitely a good idea.  I'll mess with it a bit.\n\n\t-hpa\n"},{"id":"13605","messageId":"7v1x0g5t68.fsf@assigned-by-dhcp.cox.net","threadId":"2828","inReplyTo":"439F7105.9050302@zytor.com","subject":"Re: [PATCH] git-am --one","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-14T02:06:07Z","receivedAt":"2005-12-14T02:06:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"H. Peter Anvin\" <hpa@zytor.com> writes:\n\n> This is a multi-part message in MIME format.\n> --------------080605010801030702080802\n> Content-Type: text/plain; charset=ISO-8859-1; format=flowed\n> Content-Transfer-Encoding: 7bit\n\nBTW, this is totally offtopic, but I find it somewhat puzzling\nto see somebody like you, one of Linus' trusted lieutenants, is\nsending a patch as an attachment.\n"}]}