{"thread":{"id":"31514","subject":"[PATCH] Handle \"git show\" output correctly.","startedAt":"2012-09-12T15:26:11Z","lastAt":"2012-09-12T23:05:19Z","messageCount":21,"participants":["Peter Jones","Matthieu Moy","Junio C Hamano","Dan Johnson","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"198846","messageId":"1347463571-16831-1-git-send-email-pjones@redhat.com","threadId":"31514","inReplyTo":null,"subject":"[PATCH] Handle \"git show\" output correctly.","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T15:26:11Z","receivedAt":"2012-09-12T15:26:11Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"Signed-off-by: Peter Jones <pjones@redhat.com>\n---\n git-am.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 46 insertions(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex c682d34..ebcbff7 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -216,6 +216,21 @@ check_patch_format () {\n \t\tread l2\n \t\tread l3\n \t\tcase \"$l1\" in\n+                \"commit \"*)\n+                        case \"$l2\" in\n+                        \"Author: \"*)\n+                                case \"$l3\" in\n+                                \"Date: \"*)\n+                                        patch_format=gitshow\n+                                        ;;\n+                                *)\n+                                        ;;\n+                                esac\n+                                ;;\n+                        *)\n+                                ;;\n+                        esac\n+                        ;;\n \t\t\"From \"* | \"From: \"*)\n \t\t\tpatch_format=mbox\n \t\t\t;;\n@@ -321,6 +336,37 @@ split_patches () {\n \t\tthis=\n \t\tmsgnum=\n \t\t;;\n+        gitshow)\n+\t\tthis=0\n+\t\tfor stgit in \"$@\"\n+\t\tdo\n+\t\t\tthis=`expr \"$this\" + 1`\n+\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n+\t\t\t# Perl version of The first nonemptyline after an\n+                        # empty line is the subject, and the body starts with\n+                        # the next nonempty line.\n+\t\t\tperl -ne 'BEGIN { $subject = 0 }\n+\t\t\t\tif ($subject > 1) { print ; }\n+\t\t\t\telsif (/^\\s+$/) { next ; }\n+\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n+\t\t\t\telsif (/^(From|Date)/) { print ; }\n+                                elsif (/^commit/) { next ; }\n+\t\t\t\telsif ($subject) {\n+\t\t\t\t\t$subject = 2 ;\n+\t\t\t\t\tprint \"\\n\" ;\n+                                        s/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} else {\n+\t\t\t\t\tprint \"Subject: \", $_ ;\n+\t\t\t\t\t$subject = 1;\n+\t\t\t\t}\n+\t\t\t' < \"$stgit\" > \"$dotest/$msgnum\" || clean_abort\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n+\n \thg)\n \t\tthis=0\n \t\tfor hg in \"$@\"\n-- \n1.7.11.4\n"},{"id":"198847","messageId":"1347463833-16952-1-git-send-email-pjones@redhat.com","threadId":"31514","inReplyTo":"1347463571-16831-1-git-send-email-pjones@redhat.com","subject":"[PATCH] Handle \"git show\" output correctly.","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T15:30:33Z","receivedAt":"2012-09-12T15:30:33Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"(this version with fixed tabs)\n\nSigned-off-by: Peter Jones <pjones@redhat.com>\n---\n git-am.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 45 insertions(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex c682d34..4a1a768 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -216,6 +216,21 @@ check_patch_format () {\n \t\tread l2\n \t\tread l3\n \t\tcase \"$l1\" in\n+\t\t\"commit \"*)\n+\t\t\tcase \"$l2\" in\n+\t\t\t\"Author: \"*)\n+\t\t\t\tcase \"$l3\" in\n+\t\t\t\t\"Date: \"*)\n+\t\t\t\t\tpatch_format=gitshow\n+\t\t\t\t\t;;\n+\t\t\t\t*)\n+\t\t\t\t\t;;\n+\t\t\t\tesac\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n \t\t\"From \"* | \"From: \"*)\n \t\t\tpatch_format=mbox\n \t\t\t;;\n@@ -321,6 +336,36 @@ split_patches () {\n \t\tthis=\n \t\tmsgnum=\n \t\t;;\n+\tgitshow)\n+\t\tthis=0\n+\t\tfor stgit in \"$@\"\n+\t\tdo\n+\t\t\tthis=`expr \"$this\" + 1`\n+\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n+\t\t\t# Perl version of The first nonemptyline after an\n+\t\t\t# empty line is the subject, and the body starts with\n+\t\t\t# the next nonempty line.\n+\t\t\tperl -ne 'BEGIN { $subject = 0 }\n+\t\t\t\tif ($subject > 1) { print ; }\n+\t\t\t\telsif (/^\\s+$/) { next ; }\n+\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n+\t\t\t\telsif (/^(From|Date)/) { print ; }\n+\t\t\t\telsif (/^commit/) { next ; }\n+\t\t\t\telsif ($subject) {\n+\t\t\t\t\t$subject = 2 ;\n+\t\t\t\t\tprint \"\\n\" ;\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} else {\n+\t\t\t\t\tprint \"Subject: \", $_ ;\n+\t\t\t\t\t$subject = 1;\n+\t\t\t\t}\n+\t\t\t' < \"$stgit\" > \"$dotest/$msgnum\" || clean_abort\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n \thg)\n \t\tthis=0\n \t\tfor hg in \"$@\"\n-- \n1.7.11.4\n"},{"id":"198848","messageId":"vpqpq5rz1ua.fsf@bauges.imag.fr","threadId":"31514","inReplyTo":"1347463571-16831-1-git-send-email-pjones@redhat.com","subject":"Re: [PATCH] Handle \"git show\" output correctly.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-09-12T15:40:29Z","receivedAt":"2012-09-12T15:40:29Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"> Subject: Re: [PATCH] Handle \"git show\" output correctly.\n\nNo final period please.\n\nThis does not say which part of git is made to handle \"git show\". What\nabout\n\n[PATCH] am: handle \"git show\" output correctly\n\nPeter Jones <pjones@redhat.com> writes:\n\nThis lacks a proper commit message, i.e. an answer to the \"why is this\nchange good?\" question.\n\n> Signed-off-by: Peter Jones <pjones@redhat.com>\n> ---\n>  git-am.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++\n\nDocumentation?\n\n> --- a/git-am.sh\n> +++ b/git-am.sh\n> @@ -216,6 +216,21 @@ check_patch_format () {\n>  \t\tread l2\n>  \t\tread l3\n>  \t\tcase \"$l1\" in\n> +                \"commit \"*)\n> +                        case \"$l2\" in\n> +                        \"Author: \"*)\n> +                                case \"$l3\" in\n> +                                \"Date: \"*)\n> +                                        patch_format=gitshow\n> +                                        ;;\n> +                                *)\n> +                                        ;;\n> +                                esac\n> +                                ;;\n> +                        *)\n> +                                ;;\n> +                        esac\n> +                        ;;\n\nYour code is indented with space, Git indents with tabs. Please fix this\nin your next version.\n\n>  \t\t\tpatch_format=mbox\n>  \t\t\t;;\n> @@ -321,6 +336,37 @@ split_patches () {\n>  \t\tthis=\n>  \t\tmsgnum=\n>  \t\t;;\n> +        gitshow)\n> +\t\tthis=0\n> +\t\tfor stgit in \"$@\"\n\nProbably a cut-and-paste from the stgit version, but your variable\nnaming doesn't make sense here.\n\n> +\t\tdo\n> +\t\t\tthis=`expr \"$this\" + 1`\n> +\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n> +\t\t\t# Perl version of The first nonemptyline after an\n\nWrong cut-and-paste again, the sentense doesn't parse.\n\n> +                        # empty line is the subject, and the body starts with\n> +                        # the next nonempty line.\n> +\t\t\tperl -ne 'BEGIN { $subject = 0 }\n> +\t\t\t\tif ($subject > 1) { print ; }\n> +\t\t\t\telsif (/^\\s+$/) { next ; }\n> +\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n> +\t\t\t\telsif (/^(From|Date)/) { print ; }\n> +                                elsif (/^commit/) { next ; }\n> +\t\t\t\telsif ($subject) {\n> +\t\t\t\t\t$subject = 2 ;\n> +\t\t\t\t\tprint \"\\n\" ;\n> +                                        s/^    // ;\n> +\t\t\t\t\tprint ;\n> +\t\t\t\t} else {\n> +\t\t\t\t\tprint \"Subject: \", $_ ;\n> +\t\t\t\t\t$subject = 1;\n> +\t\t\t\t}\n\nHow does this react to multi-line subject, e.g\n\nThis should be the\nsubject line.\n\nAnd this is the body.\n\n?\n\ngit format-patch will merge the lines in a single Subject: header, and\nyour version seems to take only the first line.\n\nA test showing this would be welcome.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"198849","messageId":"vpqligfz1sa.fsf@bauges.imag.fr","threadId":"31514","inReplyTo":"1347463833-16952-1-git-send-email-pjones@redhat.com","subject":"Re: [PATCH] Handle \"git show\" output correctly.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-09-12T15:41:41Z","receivedAt":"2012-09-12T15:41:41Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Peter Jones <pjones@redhat.com> writes:\n\n> (this version with fixed tabs)\n\nThis will end up being the commit message. If you add text here, then\nthe maintainer will have to manually fix it when applying (or reject\nyour patch). Please, be nice with him and put your comments below the\n--- :\n\n> Signed-off-by: Peter Jones <pjones@redhat.com>\n> ---\n\n(ie. here)\n\n>  git-am.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"198850","messageId":"1347464567-17228-1-git-send-email-pjones@redhat.com","threadId":"31514","inReplyTo":"1347463833-16952-1-git-send-email-pjones@redhat.com","subject":"[PATCH] Handle \"git show\" output correctly.","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T15:42:47Z","receivedAt":"2012-09-12T15:42:47Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"(this version with fixed tabs and the comment fixed to be actual English)\n\nSigned-off-by: Peter Jones <pjones@redhat.com>\n---\n git-am.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 45 insertions(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex c682d34..cfd7b09 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -216,6 +216,21 @@ check_patch_format () {\n \t\tread l2\n \t\tread l3\n \t\tcase \"$l1\" in\n+\t\t\"commit \"*)\n+\t\t\tcase \"$l2\" in\n+\t\t\t\"Author: \"*)\n+\t\t\t\tcase \"$l3\" in\n+\t\t\t\t\"Date: \"*)\n+\t\t\t\t\tpatch_format=gitshow\n+\t\t\t\t\t;;\n+\t\t\t\t*)\n+\t\t\t\t\t;;\n+\t\t\t\tesac\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n \t\t\"From \"* | \"From: \"*)\n \t\t\tpatch_format=mbox\n \t\t\t;;\n@@ -321,6 +336,36 @@ split_patches () {\n \t\tthis=\n \t\tmsgnum=\n \t\t;;\n+\tgitshow)\n+\t\tthis=0\n+\t\tfor stgit in \"$@\"\n+\t\tdo\n+\t\t\tthis=`expr \"$this\" + 1`\n+\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n+\t\t\t# The first nonemptyline after an empty line is the\n+\t\t\t# subject, and the body starts with the next nonempty\n+\t\t\t# line.\n+\t\t\tperl -ne 'BEGIN { $subject = 0 }\n+\t\t\t\tif ($subject > 1) { print ; }\n+\t\t\t\telsif (/^\\s+$/) { next ; }\n+\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n+\t\t\t\telsif (/^(From|Date)/) { print ; }\n+\t\t\t\telsif (/^commit/) { next ; }\n+\t\t\t\telsif ($subject) {\n+\t\t\t\t\t$subject = 2 ;\n+\t\t\t\t\tprint \"\\n\" ;\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} else {\n+\t\t\t\t\tprint \"Subject: \", $_ ;\n+\t\t\t\t\t$subject = 1;\n+\t\t\t\t}\n+\t\t\t' < \"$stgit\" > \"$dotest/$msgnum\" || clean_abort\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n \thg)\n \t\tthis=0\n \t\tfor hg in \"$@\"\n-- \n1.7.11.4\n"},{"id":"198851","messageId":"1347464989-17421-1-git-send-email-pjones@redhat.com","threadId":"31514","inReplyTo":"vpqligfz1sa.fsf@bauges.imag.fr","subject":"[PATCH] [git-am] Handle \"git show\" output correctly","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T15:49:49Z","receivedAt":"2012-09-12T15:49:49Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"This patch adds the ability for \"git am\" to accept patches in the format\ngenerated by \"git show\".  Some people erroneously use \"git show\" instead\nof \"git format-patch\", and it's nice as a maintainer to be able to\neasily take their patch rather than going back and forth with them to\nget a \"correctly\" formatted patch containing exactly the same actual\ninformation.\n\nSigned-off-by: Peter Jones <pjones@redhat.com>\n---\n git-am.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 45 insertions(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex c682d34..cfd7b09 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -216,6 +216,21 @@ check_patch_format () {\n \t\tread l2\n \t\tread l3\n \t\tcase \"$l1\" in\n+\t\t\"commit \"*)\n+\t\t\tcase \"$l2\" in\n+\t\t\t\"Author: \"*)\n+\t\t\t\tcase \"$l3\" in\n+\t\t\t\t\"Date: \"*)\n+\t\t\t\t\tpatch_format=gitshow\n+\t\t\t\t\t;;\n+\t\t\t\t*)\n+\t\t\t\t\t;;\n+\t\t\t\tesac\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n \t\t\"From \"* | \"From: \"*)\n \t\t\tpatch_format=mbox\n \t\t\t;;\n@@ -321,6 +336,36 @@ split_patches () {\n \t\tthis=\n \t\tmsgnum=\n \t\t;;\n+\tgitshow)\n+\t\tthis=0\n+\t\tfor stgit in \"$@\"\n+\t\tdo\n+\t\t\tthis=`expr \"$this\" + 1`\n+\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n+\t\t\t# The first nonemptyline after an empty line is the\n+\t\t\t# subject, and the body starts with the next nonempty\n+\t\t\t# line.\n+\t\t\tperl -ne 'BEGIN { $subject = 0 }\n+\t\t\t\tif ($subject > 1) { print ; }\n+\t\t\t\telsif (/^\\s+$/) { next ; }\n+\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n+\t\t\t\telsif (/^(From|Date)/) { print ; }\n+\t\t\t\telsif (/^commit/) { next ; }\n+\t\t\t\telsif ($subject) {\n+\t\t\t\t\t$subject = 2 ;\n+\t\t\t\t\tprint \"\\n\" ;\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} else {\n+\t\t\t\t\tprint \"Subject: \", $_ ;\n+\t\t\t\t\t$subject = 1;\n+\t\t\t\t}\n+\t\t\t' < \"$stgit\" > \"$dotest/$msgnum\" || clean_abort\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n \thg)\n \t\tthis=0\n \t\tfor hg in \"$@\"\n-- \n1.7.11.4\n"},{"id":"198852","messageId":"vpqbohbz11h.fsf@bauges.imag.fr","threadId":"31514","inReplyTo":"1347464989-17421-1-git-send-email-pjones@redhat.com","subject":"Re: [PATCH] [git-am] Handle \"git show\" output correctly","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-09-12T15:57:46Z","receivedAt":"2012-09-12T15:57:46Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Peter Jones <pjones@redhat.com> writes:\n\n> Subject: [PATCH] [git-am] Handle \"git show\" output correctly\n\nThe convention in Git is \"<subsystem>: <summary of change>\" (i.e. no\nbrackets around git-am, just am: and no capital for Handle).\n\nMy other concerns (name of stgit, multi-lines subject lines and lack of\ndocumentation) still hold.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"198858","messageId":"7v392ndu59.fsf@alter.siamese.dyndns.org","threadId":"31514","inReplyTo":"vpqbohbz11h.fsf@bauges.imag.fr","subject":"Re: [PATCH] [git-am] Handle \"git show\" output correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-12T17:32:18Z","receivedAt":"2012-09-12T17:32:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Peter Jones <pjones@redhat.com> writes:\n>\n>> Subject: [PATCH] [git-am] Handle \"git show\" output correctly\n>\n> The convention in Git is \"<subsystem>: <summary of change>\" (i.e. no\n> brackets around git-am, just am: and no capital for Handle).\n>\n> My other concerns (name of stgit, multi-lines subject lines and lack of\n> documentation) still hold.\n\nWe do not want to apply \"git show\" output that munges the log\nmessage, period.\n\nIf you want to give patches to somebody (or to yourself) via e-mail\nor via sneaker-net, \"git format-patch\" is there for you.  Do not\nbutcher \"am\" to accept a format that is not meant for patch\ntransport in the first place.\n\nIf you want to screw something in to your shelf, you would use a\nscrew and a screwdriver.  You do not try to hammer a nail using your\nscrewdriver, find that the screwdriver is not very useful as a\nhammer and modify the screwdriver to hit your nail.\n"},{"id":"198862","messageId":"1347472823.12986.3.camel@eddie.install.bos.redhat.com","threadId":"31514","inReplyTo":"vpqpq5rz1ua.fsf@bauges.imag.fr","subject":"Re: [PATCH] Handle \"git show\" output correctly.","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T18:00:23Z","receivedAt":"2012-09-12T18:00:23Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"On Wed, 2012-09-12 at 17:40 +0200, Matthieu Moy wrote:\n> \n> How does this react to multi-line subject, e.g\n> \n> This should be the\n> subject line.\n> \n> And this is the body.\n> \n> ?\n> \n> git format-patch will merge the lines in a single Subject: header, and\n> your version seems to take only the first line.\n> \n> A test showing this would be welcome. \n\nAn updated patch to fix this will be my next mail.  It's not as succinct\nas it once was, but such is life.\n\nThe two attached commits to this message can be used as a test case.\nBasically, do (in any repo)\n\ngit am 0001* 0002*\ngit show > foo.patch\ngit reset HEAD^ --hard\ngit am foo.patch\ngit show # check the output here\ngit format-patch -1\n# check 0001-bar-bar-bar-this-is-a-very-very-long-line-I-am-tired.patch\n# here.\n\nIt winds up merging the subject lines before the rest of git-am does - I\ncouldn't get it to work if I preserved the newline; for some reason I\nalways get a second newline and that's /more/ wrong.\n\n-- \n  Peter\n\n\n>From f7521f88731f9fc696dcd8e32de58cc9d98ed892 Mon Sep 17 00:00:00 2001\nFrom: Peter Jones <pjones@redhat.com>\nDate: Wed, 12 Sep 2012 13:17:11 -0400\nSubject: [PATCH 1/2] this is an example with a very long subject line which\n is completely unreasonable and nevertheless a thing.\n\nIt also has other stuff here.\n---\n foo | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 foo\n\ndiff --git a/foo b/foo\nnew file mode 100644\nindex 0000000..fa5ef85\n--- /dev/null\n+++ b/foo\n@@ -0,0 +1 @@\n+    za za za\n-- \n1.7.11.4\n\n\n\n>From bc471f2b89ada6e6ddf35b5ec2538242b5639836 Mon Sep 17 00:00:00 2001\nFrom: Peter Jones <pjones@redhat.com>\nDate: Wed, 12 Sep 2012 13:39:56 -0400\nSubject: [PATCH 2/2] bar bar bar this is a very very long line I am tired of\n this game and it is quite annoying.\n\nthis is really annoying.  I hate perl.\n    zonk.\n\nyes.\n    no.\n---\n foo | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/foo b/foo\nindex fa5ef85..3b572f4 100644\n--- a/foo\n+++ b/foo\n@@ -1 +1,2 @@\n     za za za\n+    bar bar bar\n-- \n1.7.11.4\n\n"},{"id":"198864","messageId":"1347473108.12986.6.camel@eddie.install.bos.redhat.com","threadId":"31514","inReplyTo":"7v392ndu59.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] [git-am] Handle \"git show\" output correctly","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T18:05:08Z","receivedAt":"2012-09-12T18:05:08Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"On Wed, 2012-09-12 at 10:32 -0700, Junio C Hamano wrote:\n> We do not want to apply \"git show\" output that munges the log\n> message, period.\n> \n> If you want to give patches to somebody (or to yourself) via e-mail\n> or via sneaker-net, \"git format-patch\" is there for you.  Do not\n> butcher \"am\" to accept a format that is not meant for patch\n> transport in the first place.\n> \n> If you want to screw something in to your shelf, you would use a\n> screw and a screwdriver.  You do not try to hammer a nail using your\n> screwdriver, find that the screwdriver is not very useful as a\n> hammer and modify the screwdriver to hit your nail.\n\nThat seems to be completely missing the point - people /send/ them\nwithout knowing, and as a maintainer of several projects, it's /hostile/\nto people who are trying to help by sending patches to go around in\ncircles with them about the fact that they typed the wrong command. I'd\nrather just take the patch, but right now the tools won't let me, and\nfor completely arbitrary reasons.\n\nLet me put it a different way - if you won't accept git-am handling \"git\nshow\" output because \"git show\" has output that wasn't designed to be\nparsed ever, would you be opposed to a patch that switches the \"git\nshow\" output to be something usable?\n\n-- \n  Peter\n"},{"id":"198865","messageId":"1347473304-21418-1-git-send-email-pjones@redhat.com","threadId":"31514","inReplyTo":"1347472823.12986.3.camel@eddie.install.bos.redhat.com","subject":"[PATCH] git-am: Handle \"git show\" output correctly","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T18:08:24Z","receivedAt":"2012-09-12T18:08:24Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"This patch adds the ability for \"git am\" to accept patches in the format\ngenerated by \"git show\".  Some people erroneously use \"git show\" instead\nof \"git format-patch\", and it's nice as a maintainer to be able to\neasily take their patch rather than going back and forth with them to\nget a \"correctly\" formatted patch containing exactly the same actual\ninformation.\n\nSigned-off-by: Peter Jones <pjones@redhat.com>\n---\n git-am.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 60 insertions(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex c682d34..210e9fe 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -216,6 +216,21 @@ check_patch_format () {\n \t\tread l2\n \t\tread l3\n \t\tcase \"$l1\" in\n+\t\t\"commit \"*)\n+\t\t\tcase \"$l2\" in\n+\t\t\t\"Author: \"*)\n+\t\t\t\tcase \"$l3\" in\n+\t\t\t\t\"Date: \"*)\n+\t\t\t\t\tpatch_format=gitshow\n+\t\t\t\t\t;;\n+\t\t\t\t*)\n+\t\t\t\t\t;;\n+\t\t\t\tesac\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n \t\t\"From \"* | \"From: \"*)\n \t\t\tpatch_format=mbox\n \t\t\t;;\n@@ -321,6 +336,51 @@ split_patches () {\n \t\tthis=\n \t\tmsgnum=\n \t\t;;\n+\tgitshow)\n+\t\tthis=0\n+\t\tfor patch in \"$@\"\n+\t\tdo\n+\t\t\tthis=`expr \"$this\" + 1`\n+\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n+\t\t\t# The first nonemptyline after an empty line is the\n+\t\t\t# subject, and the body starts with the next nonempty\n+\t\t\t# line.\n+\t\t\tperl -ne 'BEGIN {\n+\t\t\t\t\t$diff = 0; $subject = 0; $subjtext=\"\";\n+\t\t\t\t}\n+\t\t\t\tif ($diff == 1 || /^diff/ || /^---$/) {\n+\t\t\t\t\t$diff = 1 ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif ($subject > 1) {\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif ($subject == 1 && !/^\\s+$/) {\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\t$subjtext = \"$subjtext $_\";\n+\t\t\t\t} elsif ($subject == 1) {\n+\t\t\t\t\t$subject = 2 ;\n+\t\t\t\t\tprint \"Subject: \", $subjtext ;\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif ($subject) {\n+\t\t\t\t\tprint \"\\n\" ;\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif (/^\\s+$/) { next ; }\n+\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n+\t\t\t\telsif (/^(From|Date)/) { print ; }\n+\t\t\t\telsif (/^commit/) { next ; }\n+\t\t\t\telse {\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\t$subjtext = $_;\n+\t\t\t\t\t$subject = 1;\n+\t\t\t\t}\n+\t\t\t' < \"$patch\" > \"$dotest/$msgnum\" || clean_abort\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n \thg)\n \t\tthis=0\n \t\tfor hg in \"$@\"\n-- \n1.7.11.4\n"},{"id":"198871","messageId":"7v1ui7cb6c.fsf@alter.siamese.dyndns.org","threadId":"31514","inReplyTo":"1347473108.12986.6.camel@eddie.install.bos.redhat.com","subject":"Re: [PATCH] [git-am] Handle \"git show\" output correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-12T19:07:23Z","receivedAt":"2012-09-12T19:07:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Jones <pjones@redhat.com> writes:\n\n> Let me put it a different way - if you won't accept git-am handling \"git\n> show\" output because \"git show\" has output that wasn't designed to be\n> parsed ever, would you be opposed to a patch that switches the \"git\n> show\" output to be something usable?\n\nThe output from the command is optimized for humans, but you could\ninvoke \"git show --pretty=email\" if you want to, so I do not think\nyou need any patch to do that.\n"},{"id":"198876","messageId":"7vtxv3atvu.fsf@alter.siamese.dyndns.org","threadId":"31514","inReplyTo":"1347473304-21418-1-git-send-email-pjones@redhat.com","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-12T20:06:13Z","receivedAt":"2012-09-12T20:06:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Jones <pjones@redhat.com> writes:\n\n> This patch adds the ability for \"git am\" to accept patches in the format\n> generated by \"git show\".  Some people erroneously use \"git show\" instead\n> of \"git format-patch\", and it's nice as a maintainer to be able to\n> easily take their patch rather than going back and forth with them to\n> get a \"correctly\" formatted patch containing exactly the same actual\n> information.\n>\n> Signed-off-by: Peter Jones <pjones@redhat.com>\n> ---\n>  git-am.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 60 insertions(+)\n>\n> diff --git a/git-am.sh b/git-am.sh\n> index c682d34..210e9fe 100755\n> --- a/git-am.sh\n> +++ b/git-am.sh\n> @@ -216,6 +216,21 @@ check_patch_format () {\n>  \t\tread l2\n>  \t\tread l3\n>  \t\tcase \"$l1\" in\n> +\t\t\"commit \"*)\n> +\t\t\tcase \"$l2\" in\n> +\t\t\t\"Author: \"*)\n> +\t\t\t\tcase \"$l3\" in\n> +\t\t\t\t\"Date: \"*)\n> +\t\t\t\t\tpatch_format=gitshow\n> +\t\t\t\t\t;;\n> +\t\t\t\t*)\n> +\t\t\t\t\t;;\n> +\t\t\t\tesac\n> +\t\t\t\t;;\n> +\t\t\t*)\n> +\t\t\t\t;;\n> +\t\t\tesac\n> +\t\t\t;;\n\nAt least the inner one could become easier to read by losing one\nlevel of nesting, e.g.\n\n\tcase \"$l2,,$l3\" in\n        \"Author: *\",,\"Date: \")\n\t\tfound it\n                ;;\n\tesac\n\nI wonder what the severity of the damage if we misidentify the patch\nformat in this function would be?  If it is severe enough, the check\nfor the first line may want to become a bit more strict to avoid\nmisidentification (e.g. expr \"$l1\" : 'commit [0-9a-f]\\{40\\}$').\nPerhaps we don't care.  I dunno.\n\n> @@ -321,6 +336,51 @@ split_patches () {\n>  \t\tthis=\n>  \t\tmsgnum=\n>  \t\t;;\n> +\tgitshow)\n> +\t\tthis=0\n> +\t\tfor patch in \"$@\"\n> +\t\tdo\n\nSo each input file is expected to be nothing but an output from \"git\nshow\" for a single commit; in other words, not concatenation of\nthem, nor just an e-mail message that has \"git show\" output\ncopy&pasted in the body with some other cruft, but plausibly was\ndelibered as a separate attachment file.\n\nI somehow was visualizing that you were trying to accept mails I\nsometimes see here like:\n\n\tFrom: somebody\n        Date: someday\n\n        Hi, a long winded discussion that talks about the motivation\n        behind the patch comes here.\n\n\tcommit 4d8c4db13c8c4c79b6fc0a38ff52d85d3543aa7a\n        Author: A U Thor <author@example.com>\n        Date: Tue Sep 11 12:34:56 2012 +0900\n\n\t    a one liner that just says \"bugfix\" and nothing else\n\n\tdiff --git ....\n\nand that was one of the reasons I thought (but didn't say in my\nresponses) \"Why bother?  When running 'am' on such a message you\nwill have to edit the message to move things around anyway\".\n\nIf the target is a stand-alone \"git show\" output, at least we do not\nhave to worry about such a case.\n\n> +\t\t\tthis=`expr \"$this\" + 1`\n> +\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n> +\t\t\t# The first nonemptyline after an empty line is the\n> +\t\t\t# subject, and the body starts with the next nonempty\n> +\t\t\t# line.\n> +\t\t\tperl -ne 'BEGIN {\n> +\t\t\t\t\t$diff = 0; $subject = 0; $subjtext=\"\";\n> +\t\t\t\t}\n> +\t\t\t\tif ($diff == 1 || /^diff/ || /^---$/) {\n> +\t\t\t\t\t$diff = 1 ;\n> +\t\t\t\t\tprint ;\n> +\t\t\t\t} elsif ($subject > 1) {\n> +\t\t\t\t\ts/^    // ;\n> +\t\t\t\t\tprint ;\n> +\t\t\t\t} elsif ($subject == 1 && !/^\\s+$/) {\n> +\t\t\t\t\ts/^    // ;\n> +\t\t\t\t\t$subjtext = \"$subjtext $_\";\n> +\t\t\t\t} elsif ($subject == 1) {\n> +\t\t\t\t\t$subject = 2 ;\n> +\t\t\t\t\tprint \"Subject: \", $subjtext ;\n> +\t\t\t\t\ts/^    // ;\n> +\t\t\t\t\tprint ;\n> +\t\t\t\t} elsif ($subject) {\n> +\t\t\t\t\tprint \"\\n\" ;\n> +\t\t\t\t\ts/^    // ;\n> +\t\t\t\t\tprint ;\n> +\t\t\t\t} elsif (/^\\s+$/) { next ; }\n> +\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n> +\t\t\t\telsif (/^(From|Date)/) { print ; }\n\nWhere does \"^From\" come from? Should this be /^Date: / instead?\n\n> +\t\t\t\telsif (/^commit/) { next ; }\n> +\t\t\t\telse {\n> +\t\t\t\t\ts/^    // ;\n> +\t\t\t\t\t$subjtext = $_;\n> +\t\t\t\t\t$subject = 1;\n> +\t\t\t\t}\n> +\t\t\t' < \"$patch\" > \"$dotest/$msgnum\" || clean_abort\n> +\t\tdone\n\nThis reminds me of another reason why I am hesitant to make \"am\"\ntake output from \"git show\".  Unlike format-patch output, \"Author:\"\nand \"Date:\" in its output, because it is meant for human\nconsumption, might be a fair game for i18n/l10n (the first line\n\"commit [0-9][a-f]{40}\" is not likely to change, though).\n\n> +\t\techo \"$this\" > \"$dotest/last\"\n> +\t\tthis=\n> +\t\tmsgnum=\n> +\t\t;;\n>  \thg)\n>  \t\tthis=0\n>  \t\tfor hg in \"$@\"\n"},{"id":"198880","messageId":"1347482918.21933.5.camel@eddie.install.bos.redhat.com","threadId":"31514","inReplyTo":"7vtxv3atvu.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T20:48:38Z","receivedAt":"2012-09-12T20:48:38Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"On Wed, 2012-09-12 at 13:06 -0700, Junio C Hamano wrote:\n> Peter Jones <pjones@redhat.com> writes:\n> \n> > This patch adds the ability for \"git am\" to accept patches in the format\n> > generated by \"git show\".  Some people erroneously use \"git show\" instead\n> > of \"git format-patch\", and it's nice as a maintainer to be able to\n> > easily take their patch rather than going back and forth with them to\n> > get a \"correctly\" formatted patch containing exactly the same actual\n> > information.\n> >\n> > Signed-off-by: Peter Jones <pjones@redhat.com>\n> > ---\n> >  git-am.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 60 insertions(+)\n> >\n> > diff --git a/git-am.sh b/git-am.sh\n> > index c682d34..210e9fe 100755\n> > --- a/git-am.sh\n> > +++ b/git-am.sh\n> > @@ -216,6 +216,21 @@ check_patch_format () {\n> >  \t\tread l2\n> >  \t\tread l3\n> >  \t\tcase \"$l1\" in\n> > +\t\t\"commit \"*)\n> > +\t\t\tcase \"$l2\" in\n> > +\t\t\t\"Author: \"*)\n> > +\t\t\t\tcase \"$l3\" in\n> > +\t\t\t\t\"Date: \"*)\n> > +\t\t\t\t\tpatch_format=gitshow\n> > +\t\t\t\t\t;;\n> > +\t\t\t\t*)\n> > +\t\t\t\t\t;;\n> > +\t\t\t\tesac\n> > +\t\t\t\t;;\n> > +\t\t\t*)\n> > +\t\t\t\t;;\n> > +\t\t\tesac\n> > +\t\t\t;;\n> \n> At least the inner one could become easier to read by losing one\n> level of nesting, e.g.\n> \n> \tcase \"$l2,,$l3\" in\n>         \"Author: *\",,\"Date: \")\n> \t\tfound it\n>                 ;;\n> \tesac\n\nYeah, I can do that.\n\n> I wonder what the severity of the damage if we misidentify the patch\n> format in this function would be?  If it is severe enough, the check\n> for the first line may want to become a bit more strict to avoid\n> misidentification (e.g. expr \"$l1\" : 'commit [0-9a-f]\\{40\\}$').\n> Perhaps we don't care.  I dunno.\n\nI hadn't really even considered it - are there other formats that use\ncommit and author which git-am.sh is supposed to support? It seems as\nthough if we get something wrong you'll wind up in clean_abort at some\npoint anyway.  At worst your patch will still be there and you'll need\nto do \"git am --abort\".\n\n> > @@ -321,6 +336,51 @@ split_patches () {\n> >  \t\tthis=\n> >  \t\tmsgnum=\n> >  \t\t;;\n> > +\tgitshow)\n> > +\t\tthis=0\n> > +\t\tfor patch in \"$@\"\n> > +\t\tdo\n> \n> So each input file is expected to be nothing but an output from \"git\n> show\" for a single commit; in other words, not concatenation of\n> them, nor just an e-mail message that has \"git show\" output\n> copy&pasted in the body with some other cruft, but plausibly was\n> delibered as a separate attachment file.\n> \n> I somehow was visualizing that you were trying to accept mails I\n> sometimes see here like:\n> \n> \tFrom: somebody\n>         Date: someday\n> \n>         Hi, a long winded discussion that talks about the motivation\n>         behind the patch comes here.\n> \n> \tcommit 4d8c4db13c8c4c79b6fc0a38ff52d85d3543aa7a\n>         Author: A U Thor <author@example.com>\n>         Date: Tue Sep 11 12:34:56 2012 +0900\n> \n> \t    a one liner that just says \"bugfix\" and nothing else\n> \n> \tdiff --git ....\n> \n> and that was one of the reasons I thought (but didn't say in my\n> responses) \"Why bother?  When running 'am' on such a message you\n> will have to edit the message to move things around anyway\".\n\nYeah, that sounds like madness.\n\n> If the target is a stand-alone \"git show\" output, at least we do not\n> have to worry about such a case.\n\nRight.\n\n> \n> > +\t\t\tthis=`expr \"$this\" + 1`\n> > +\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n> > +\t\t\t# The first nonemptyline after an empty line is the\n> > +\t\t\t# subject, and the body starts with the next nonempty\n> > +\t\t\t# line.\n> > +\t\t\tperl -ne 'BEGIN {\n> > +\t\t\t\t\t$diff = 0; $subject = 0; $subjtext=\"\";\n> > +\t\t\t\t}\n> > +\t\t\t\tif ($diff == 1 || /^diff/ || /^---$/) {\n> > +\t\t\t\t\t$diff = 1 ;\n> > +\t\t\t\t\tprint ;\n> > +\t\t\t\t} elsif ($subject > 1) {\n> > +\t\t\t\t\ts/^    // ;\n> > +\t\t\t\t\tprint ;\n> > +\t\t\t\t} elsif ($subject == 1 && !/^\\s+$/) {\n> > +\t\t\t\t\ts/^    // ;\n> > +\t\t\t\t\t$subjtext = \"$subjtext $_\";\n> > +\t\t\t\t} elsif ($subject == 1) {\n> > +\t\t\t\t\t$subject = 2 ;\n> > +\t\t\t\t\tprint \"Subject: \", $subjtext ;\n> > +\t\t\t\t\ts/^    // ;\n> > +\t\t\t\t\tprint ;\n> > +\t\t\t\t} elsif ($subject) {\n> > +\t\t\t\t\tprint \"\\n\" ;\n> > +\t\t\t\t\ts/^    // ;\n> > +\t\t\t\t\tprint ;\n> > +\t\t\t\t} elsif (/^\\s+$/) { next ; }\n> > +\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n> > +\t\t\t\telsif (/^(From|Date)/) { print ; }\n> \n> Where does \"^From\" come from? Should this be /^Date: / instead?\n\nEntirely copy-paste error on my part.  I'll fix it for the next version.\n\n> \n> > +\t\t\t\telsif (/^commit/) { next ; }\n> > +\t\t\t\telse {\n> > +\t\t\t\t\ts/^    // ;\n> > +\t\t\t\t\t$subjtext = $_;\n> > +\t\t\t\t\t$subject = 1;\n> > +\t\t\t\t}\n> > +\t\t\t' < \"$patch\" > \"$dotest/$msgnum\" || clean_abort\n> > +\t\tdone\n> \n> This reminds me of another reason why I am hesitant to make \"am\"\n> take output from \"git show\".  Unlike format-patch output, \"Author:\"\n> and \"Date:\" in its output, because it is meant for human\n> consumption, might be a fair game for i18n/l10n (the first line\n> \"commit [0-9][a-f]{40}\" is not likely to change, though).\n\nWell, if that happens, maybe we could regexp match on\n\"[[:alnum:]_-]+: /someexprthatlookslikeanemailaddress/\" ?  But we could\nalso just wait to cross that bridge until we get to it?  Even if that\ndoes get translated later, the current patch would continue to work for\nEnglish, so even in that case it's not totally worthless.\n\n-- \n  Peter\n"},{"id":"198883","messageId":"1347483787-25623-1-git-send-email-pjones@redhat.com","threadId":"31514","inReplyTo":"1347482918.21933.5.camel@eddie.install.bos.redhat.com","subject":"[PATCH] git-am: Handle \"git show\" output correctly","fromName":"Peter Jones","fromEmail":"pjones@redhat.com","sentAt":"2012-09-12T21:03:07Z","receivedAt":"2012-09-12T21:03:07Z","isPatch":true,"sender":{"key":"pjones@redhat.com","avatar":"https://gravatar.com/avatar/a7ee1bf5628ca7f607facec51285b8328294c3f331d87410fe8558beda46f896?d=mp&s=160"},"body":"This patch adds the ability for \"git am\" to accept patches in the format\ngenerated by \"git show\".  Some people erroneously use \"git show\" instead\nof \"git format-patch\", and it's nice as a maintainer to be able to\neasily take their patch rather than going back and forth with them to\nget a \"correctly\" formatted patch containing exactly the same actual\ninformation.\n\nSigned-off-by: Peter Jones <pjones@redhat.com>\n---\n git-am.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 57 insertions(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex c682d34..d20f249 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -216,6 +216,18 @@ check_patch_format () {\n \t\tread l2\n \t\tread l3\n \t\tcase \"$l1\" in\n+\t\t\"commit \"*)\n+\t\t\tcase \"$l2,,$l3\" in\n+\t\t\t\"Author: \"*,,\"Date: \"*)\n+\t\t\t\tif expr \"$l1\" : 'commit [0-9a-f]\\{40\\}$' \\\n+\t\t\t\t\t\t>/dev/null ; then\n+\t\t\t\t\tpatch_format=gitshow\n+\t\t\t\tfi\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n \t\t\"From \"* | \"From: \"*)\n \t\t\tpatch_format=mbox\n \t\t\t;;\n@@ -321,6 +333,51 @@ split_patches () {\n \t\tthis=\n \t\tmsgnum=\n \t\t;;\n+\tgitshow)\n+\t\tthis=0\n+\t\tfor patch in \"$@\"\n+\t\tdo\n+\t\t\tthis=`expr \"$this\" + 1`\n+\t\t\tmsgnum=`printf \"%0${prec}d\" $this`\n+\t\t\t# The first nonemptyline after an empty line is the\n+\t\t\t# subject, and the body starts with the next nonempty\n+\t\t\t# line.\n+\t\t\tperl -ne 'BEGIN {\n+\t\t\t\t\t$diff = 0; $subject = 0; $subjtext=\"\";\n+\t\t\t\t}\n+\t\t\t\tif ($diff == 1 || /^diff/ || /^---$/) {\n+\t\t\t\t\t$diff = 1 ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif ($subject > 1) {\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif ($subject == 1 && !/^\\s+$/) {\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\t$subjtext = \"$subjtext $_\";\n+\t\t\t\t} elsif ($subject == 1) {\n+\t\t\t\t\t$subject = 2 ;\n+\t\t\t\t\tprint \"Subject: \", $subjtext ;\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif ($subject) {\n+\t\t\t\t\tprint \"\\n\" ;\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\tprint ;\n+\t\t\t\t} elsif (/^\\s+$/) { next ; }\n+\t\t\t\telsif (/^Author:/) { s/Author/From/ ; print ;}\n+\t\t\t\telsif (/^Date:/) { print ; }\n+\t\t\t\telsif (/^commit/) { next ; }\n+\t\t\t\telse {\n+\t\t\t\t\ts/^    // ;\n+\t\t\t\t\t$subjtext = $_;\n+\t\t\t\t\t$subject = 1;\n+\t\t\t\t}\n+\t\t\t' < \"$patch\" > \"$dotest/$msgnum\" || clean_abort\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n \thg)\n \t\tthis=0\n \t\tfor hg in \"$@\"\n-- \n1.7.11.4\n"},{"id":"198885","messageId":"7vpq5raqiq.fsf@alter.siamese.dyndns.org","threadId":"31514","inReplyTo":"1347482918.21933.5.camel@eddie.install.bos.redhat.com","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-12T21:18:53Z","receivedAt":"2012-09-12T21:18:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Jones <pjones@redhat.com> writes:\n\n> Well, if that happens, maybe we could regexp match on\n> \"[[:alnum:]_-]+: /someexprthatlookslikeanemailaddress/\" ?\n\nI doubt that would be even reliably done.\n\n> But we could\n> also just wait to cross that bridge until we get to it?\n\nNot really.  If we start encouraging people to use \"git show\" output\nas a kosher input to \"am\", we would have to support such use\nforever, and we end up painting ourselves in a corner we cannot get\nout of easily.\n"},{"id":"198887","messageId":"CAPBPrntHOpDaH3cSNiKKxVJDbZTpPrLc99TgPM_GdoXecUvs9w@mail.gmail.com","threadId":"31514","inReplyTo":"7vpq5raqiq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Dan Johnson","fromEmail":"computerdruid@gmail.com","sentAt":"2012-09-12T21:26:39Z","receivedAt":"2012-09-12T21:26:39Z","isPatch":true,"sender":{"key":"computerdruid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/34696?v=4"},"body":"On Wed, Sep 12, 2012 at 5:18 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Peter Jones <pjones@redhat.com> writes:\n>\n>> Well, if that happens, maybe we could regexp match on\n>> \"[[:alnum:]_-]+: /someexprthatlookslikeanemailaddress/\" ?\n>\n> I doubt that would be even reliably done.\n>\n>> But we could\n>> also just wait to cross that bridge until we get to it?\n>\n> Not really.  If we start encouraging people to use \"git show\" output\n> as a kosher input to \"am\", we would have to support such use\n> forever, and we end up painting ourselves in a corner we cannot get\n> out of easily.\n\nIf git am emitted a warning when accepting \"git show\" output, it seems\nlike it would support Peter's use-case without encouraging bad\nbehavior?\n\n-- \n-Dan\n"},{"id":"198889","messageId":"7vhar2c29s.fsf@alter.siamese.dyndns.org","threadId":"31514","inReplyTo":"CAPBPrntHOpDaH3cSNiKKxVJDbZTpPrLc99TgPM_GdoXecUvs9w@mail.gmail.com","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-12T22:19:43Z","receivedAt":"2012-09-12T22:19:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan Johnson <computerdruid@gmail.com> writes:\n\n>> Not really.  If we start encouraging people to use \"git show\" output\n>> as a kosher input to \"am\", we would have to support such use\n>> forever, and we end up painting ourselves in a corner we cannot get\n>> out of easily.\n>\n> If git am emitted a warning when accepting \"git show\" output, it seems\n> like it would support Peter's use-case without encouraging bad\n> behavior?\n\nAre you seriously suggesting me to sell to our users a new feature\nsaying \"this does not work reliably, we would not recommend using\nit, no, really, don't trust it.\" from the day the feature is\nintroduced, especially when we know it will not be \"the feature does\nnot work well yet, but it will, we promise\" but is \"and it may become\nworse in the future\"?\n\nI do not see much point in doing that.\n\nBesides, what bad behaviour do we avoid from encouraging with such\nan approach?  As Peter said, the problem is not on the part of the\nuser who ended up with an output from \"git show\", when he really\nwants output from \"git format-patch\".  Giving the warning to the\nuser of \"git am\" is too late.\n\nI may be able to be pursuaded to swallow a new script somewhere in\nthe contrib/ hierarchy that takes a \"git show\" output and formats it\nto look like \"format-patch\" output to be fed to \"git am\".  That way,\nwhen a user has trouble with its parsing of \"git show\" output, at\nleast we can ask for the output of the format massaging step to help\nus diagnose where the problem lies.\n"},{"id":"198890","messageId":"CAPBPrntXCDHwWkYV3pnj3+d8FCZCmEVPHkSxyVg0Jzd0tzZsGA@mail.gmail.com","threadId":"31514","inReplyTo":"7vhar2c29s.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Dan Johnson","fromEmail":"computerdruid@gmail.com","sentAt":"2012-09-12T22:31:03Z","receivedAt":"2012-09-12T22:31:03Z","isPatch":true,"sender":{"key":"computerdruid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/34696?v=4"},"body":"On Wed, Sep 12, 2012 at 6:19 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Dan Johnson <computerdruid@gmail.com> writes:\n>\n>>> Not really.  If we start encouraging people to use \"git show\" output\n>>> as a kosher input to \"am\", we would have to support such use\n>>> forever, and we end up painting ourselves in a corner we cannot get\n>>> out of easily.\n>>\n>> If git am emitted a warning when accepting \"git show\" output, it seems\n>> like it would support Peter's use-case without encouraging bad\n>> behavior?\n>\n> Are you seriously suggesting me to sell to our users a new feature\n> saying \"this does not work reliably, we would not recommend using\n> it, no, really, don't trust it.\" from the day the feature is\n> introduced, especially when we know it will not be \"the feature does\n> not work well yet, but it will, we promise\" but is \"and it may become\n> worse in the future\"?\n>\n> I do not see much point in doing that.\nFair enough.\n\n> Besides, what bad behaviour do we avoid from encouraging with such\n> an approach?  As Peter said, the problem is not on the part of the\n> user who ended up with an output from \"git show\", when he really\n> wants output from \"git format-patch\".  Giving the warning to the\n> user of \"git am\" is too late.\nI was assuming Peter would accept the patch, and reply with a \"in the\nfuture, please submit the output of format-patch\", thus correcting the\nsubmitter's behavior. This warning would serve someone who did not\nknow that they wanted the output of format-patch, and hopefully teach\nthem to send such a reply message.\n\n> I may be able to be pursuaded to swallow a new script somewhere in\n> the contrib/ hierarchy that takes a \"git show\" output and formats it\n> to look like \"format-patch\" output to be fed to \"git am\".  That way,\n> when a user has trouble with its parsing of \"git show\" output, at\n> least we can ask for the output of the format massaging step to help\n> us diagnose where the problem lies.\n\nThat sounds like a better approach to me as well.\n\n-- \n-Dan\n"},{"id":"198893","messageId":"50510F7C.4080700@op5.se","threadId":"31514","inReplyTo":"7vhar2c29s.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2012-09-12T22:41:00Z","receivedAt":"2012-09-12T22:41:00Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"On 09/13/2012 12:19 AM, Junio C Hamano wrote:\n> Dan Johnson <computerdruid@gmail.com> writes:\n> \n>>> Not really.  If we start encouraging people to use \"git show\" output\n>>> as a kosher input to \"am\", we would have to support such use\n>>> forever, and we end up painting ourselves in a corner we cannot get\n>>> out of easily.\n>>\n>> If git am emitted a warning when accepting \"git show\" output, it seems\n>> like it would support Peter's use-case without encouraging bad\n>> behavior?\n> \n> Are you seriously suggesting me to sell to our users a new feature\n> saying \"this does not work reliably, we would not recommend using\n> it, no, really, don't trust it.\" from the day the feature is\n> introduced, especially when we know it will not be \"the feature does\n> not work well yet, but it will, we promise\" but is \"and it may become\n> worse in the future\"?\n> \n> I do not see much point in doing that.\n> \n> Besides, what bad behaviour do we avoid from encouraging with such\n> an approach?  As Peter said, the problem is not on the part of the\n> user who ended up with an output from \"git show\", when he really\n> wants output from \"git format-patch\".  Giving the warning to the\n> user of \"git am\" is too late.\n> \n\nIt might be enough to either enable format-patch output or print a\nwarning to stderr when stdout is not a tty. I believe that would at\nleast mitigate the problem, and it might educate the user as well.\nWe already modify output format when stdout is not a tty (removing\ncolors), so we're not giving guarantees about its format when it's\npiped somewhere. I believe that would provide almost every scenario\nwith the expected outcome (including 'git show | grep'), but there\nwill be a handful of very surprised people as well.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n\nConsidering the successes of the wars on alcohol, poverty, drugs and\nterror, I think we should give some serious thought to declaring war\non peace.\n"},{"id":"198896","messageId":"7v4nn2c05s.fsf@alter.siamese.dyndns.org","threadId":"31514","inReplyTo":"CAPBPrntXCDHwWkYV3pnj3+d8FCZCmEVPHkSxyVg0Jzd0tzZsGA@mail.gmail.com","subject":"Re: [PATCH] git-am: Handle \"git show\" output correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-12T23:05:19Z","receivedAt":"2012-09-12T23:05:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan Johnson <computerdruid@gmail.com> writes:\n\n> I was assuming Peter would accept the patch, and reply with a \"in the\n> future, please submit the output of format-patch\", thus correcting the\n> submitter's behavior. This warning would serve someone who did not\n> know that they wanted the output of format-patch, and hopefully teach\n> them to send such a reply message.\n\n\"Next time, please do this\" rarely has worked in practice.  This is\nbecause the moment you accepted the current patch, you have already\nlost the \"carrot\" ;-)\n"}]}