{"thread":{"id":"19631","subject":"[PATCHv3 (resend) 0/4] git-am foreign patch support","startedAt":"2009-06-01T23:10:37Z","lastAt":"2009-06-02T15:21:39Z","messageCount":7,"participants":["Giuseppe Bilotta","Nanako Shiraishi","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"115218","messageId":"1243897841-8923-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"19631","inReplyTo":null,"subject":"[PATCHv3 (resend) 0/4] git-am foreign patch support","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-06-01T23:10:37Z","receivedAt":"2009-06-01T23:10:37Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Junio mentioned that he's ready to apply the series cleanly, so here's\na resend rebased on latest 'next' and without any 'bis' patches ;-)\n\nGiuseppe Bilotta (4):\n  git-am foreign patch support: introduce patch_format\n  git-am foreign patch support: autodetect some patch formats\n  git-am foreign patch support: StGIT support\n  git-am: refactor 'cleaning up and aborting'\n\n git-am.sh |  133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 129 insertions(+), 4 deletions(-)\n"},{"id":"115219","messageId":"1243897841-8923-2-git-send-email-giuseppe.bilotta@gmail.com","threadId":"19631","inReplyTo":"1243897841-8923-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 (resend) 1/4] git-am foreign patch support: introduce patch_format","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-06-01T23:10:38Z","receivedAt":"2009-06-01T23:10:38Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Set up a framework to allow git-am to support patches which are not in\nmailbox format. Introduce a patch_format variable that presently can\nonly be set from the command line, defaulting to 'mbox' (the only\nsupported format) if not specified.\n---\n git-am.sh |   37 +++++++++++++++++++++++++++++++++----\n 1 files changed, 33 insertions(+), 4 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 578780b..da160de 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -18,6 +18,7 @@ whitespace=     pass it through git-apply\n directory=      pass it through git-apply\n C=              pass it through git-apply\n p=              pass it through git-apply\n+patch-format=   format the patch(es) are in\n reject          pass it through git-apply\n resolvemsg=     override error message when patch failure occurs\n r,resolved      to be used after a patch failure\n@@ -133,6 +134,32 @@ It does not apply to blobs recorded in its index.\"\n     unset GITHEAD_$his_tree\n }\n \n+patch_format=\n+\n+check_patch_format () {\n+\t# early return if patch_format was set from the command line\n+\tif test -n \"$patch_format\"\n+\tthen\n+\t\treturn 0\n+\tfi\n+\tpatch_format=mbox\n+}\n+\n+split_patches () {\n+\tcase \"$patch_format\" in\n+\tmbox)\n+\t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b -- \"$@\" > \"$dotest/last\" ||  {\n+\t\t\trm -fr \"$dotest\"\n+\t\t\texit 1\n+\t\t}\n+\t\t;;\n+\t*)\n+\t\techo \"Patch format $patch_format is not supported.\"\n+\t\texit 1\n+\t\t;;\n+\tesac\n+}\n+\n prec=4\n dotest=\"$GIT_DIR/rebase-apply\"\n sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=\n@@ -175,6 +202,8 @@ do\n \t\tgit_apply_opt=\"$git_apply_opt $(sq \"$1=$2\")\"; shift ;;\n \t-C|-p)\n \t\tgit_apply_opt=\"$git_apply_opt $(sq \"$1$2\")\"; shift ;;\n+\t--patch-format)\n+\t\tshift ; patch_format=\"$1\" ;;\n \t--reject)\n \t\tgit_apply_opt=\"$git_apply_opt $1\" ;;\n \t--committer-date-is-author-date)\n@@ -274,10 +303,10 @@ else\n \t\tdone\n \t\tshift\n \tfi\n-\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b -- \"$@\" > \"$dotest/last\" ||  {\n-\t\trm -fr \"$dotest\"\n-\t\texit 1\n-\t}\n+\n+\tcheck_patch_format \"$@\"\n+\n+\tsplit_patches \"$@\"\n \n \t# -s, -u, -k, --whitespace, -3, -C and -p flags are kept\n \t# for the resuming session after a patch failure.\n-- \n1.6.3.1.282.g9f93\n"},{"id":"115221","messageId":"1243897841-8923-3-git-send-email-giuseppe.bilotta@gmail.com","threadId":"19631","inReplyTo":"1243897841-8923-2-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 (resend) 2/4] git-am foreign patch support: autodetect some patch formats","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-06-01T23:10:39Z","receivedAt":"2009-06-01T23:10:39Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Default to mbox format if input is from stdin. Otherwise, look at the\nfirst few lines of the first patch to try to guess its format.\n\nInclude checks for mailboxes, stgit patch series, stgit single patches\nand hg patches.\n---\n git-am.sh |   40 +++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 39 insertions(+), 1 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex da160de..8519701 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -142,7 +142,45 @@ check_patch_format () {\n \tthen\n \t\treturn 0\n \tfi\n-\tpatch_format=mbox\n+\n+\t# we default to mbox format if input is from stdin and for\n+\t# directories\n+\tif test $# = 0 || test \"x$1\" = \"x-\" || test -d \"$1\"\n+\tthen\n+\t\tpatch_format=mbox\n+\t\treturn 0\n+\tfi\n+\n+\t# otherwise, check the first few lines of the first patch to try\n+\t# to detect its format\n+\t{\n+\t\tread l1\n+\t\tread l2\n+\t\tread l3\n+\t\tcase \"$l1\" in\n+\t\t\"From \"*|\"From: \"*)\n+\t\t\tpatch_format=mbox\n+\t\t\t;;\n+\t\t'# This series applies on GIT commit'*)\n+\t\t\tpatch_format=stgit-series\n+\t\t\t;;\n+\t\t\"# HG changeset patch\")\n+\t\t\tpatch_format=hg\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# if the second line is empty and the third is\n+\t\t\t# a From, Author or Date entry, this is very\n+\t\t\t# likely an StGIT patch\n+\t\t\tcase \"$l2,$l3\" in\n+\t\t\t,\"From: \"*|,\"Author: \"*|,\"Date: \"*)\n+\t\t\t\tpatch_format=stgit\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\t} < \"$1\"\n }\n \n split_patches () {\n-- \n1.6.3.1.282.g9f93\n"},{"id":"115222","messageId":"1243897841-8923-4-git-send-email-giuseppe.bilotta@gmail.com","threadId":"19631","inReplyTo":"1243897841-8923-3-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 (resend) 3/4] git-am foreign patch support: StGIT support","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-06-01T23:10:40Z","receivedAt":"2009-06-01T23:10:40Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Support StGIT patches by implementing a simple perl-based converter\nmimicking StGIT's own parse_patch. Also support StGIT patch series by\n'exploding' the index into a list of files and re-running the mail\nsplitting with patch_format set to stgit.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n git-am.sh |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 57 insertions(+), 0 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 8519701..d05c9b4 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -191,6 +191,63 @@ split_patches () {\n \t\t\texit 1\n \t\t}\n \t\t;;\n+\tstgit-series)\n+\t\tif test $# -ne 1\n+\t\tthen\n+\t\t\techo \"Only one StGIT patch series can be applied at once\"\n+\t\t\texit 1\n+\t\tfi\n+\t\tseries_dir=`dirname \"$1\"`\n+\t\tseries_file=\"$1\"\n+\t\tshift\n+\t\t{\n+\t\t\tset x\n+\t\t\twhile read filename\n+\t\t\tdo\n+\t\t\t\tset \"$@\" \"$series_dir/$filename\"\n+\t\t\tdone\n+\t\t\t# remove the safety x\n+\t\t\tshift\n+\t\t\t# remove the arg coming from the first-line comment\n+\t\t\tshift\n+\t\t} < \"$series_file\"\n+\t\t# set the patch format appropriately\n+\t\tpatch_format=stgit\n+\t\t# now handle the actual StGIT patches\n+\t\tsplit_patches \"$@\"\n+\t\t;;\n+\tstgit)\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 StGIT parse_patch. The first nonemptyline\n+\t\t\t# not starting with Author, From or Date is the\n+\t\t\t# subject, and the body starts with the next nonempty\n+\t\t\t# line not starting with Author, From or Date\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:/) { print s/Author/From/ ; }\n+\t\t\t\telsif (/^(From|Date)/) { print ; }\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\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\" || {\n+\t\t\t\techo \"Failed to import $patch_format patch $stgit\"\n+\t\t\t\texit 1\n+\t\t\t}\n+\t\tdone\n+\t\techo \"$this\" > \"$dotest/last\"\n+\t\tthis=\n+\t\tmsgnum=\n+\t\t;;\n \t*)\n \t\techo \"Patch format $patch_format is not supported.\"\n \t\texit 1\n-- \n1.6.3.1.282.g9f93\n"},{"id":"115220","messageId":"1243897841-8923-5-git-send-email-giuseppe.bilotta@gmail.com","threadId":"19631","inReplyTo":"1243897841-8923-4-git-send-email-giuseppe.bilotta@gmail.com","subject":"[PATCHv3 (resend) 4/4] git-am: refactor 'cleaning up and aborting'","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-06-01T23:10:41Z","receivedAt":"2009-06-01T23:10:41Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Introduce a clean_abort function that echoes an optional error message\nto standard error, removes the dotest directory and exits with status 1.\n\nUse it when patch format detection or patch splitting fails early.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n git-am.sh |   29 +++++++++++++++--------------\n 1 files changed, 15 insertions(+), 14 deletions(-)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex d05c9b4..e8b2bc2 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -134,6 +134,15 @@ It does not apply to blobs recorded in its index.\"\n     unset GITHEAD_$his_tree\n }\n \n+clean_abort () {\n+\tif test $# -gt 0\n+\tthen\n+\t\techo \"$@\" > /dev/stderr\n+\tfi\n+\trm -fr \"$dotest\"\n+\texit 1\n+}\n+\n patch_format=\n \n check_patch_format () {\n@@ -180,22 +189,18 @@ check_patch_format () {\n \t\t\tesac\n \t\t\t;;\n \t\tesac\n-\t} < \"$1\"\n+\t} < \"$1\" || clean_abort\n }\n \n split_patches () {\n \tcase \"$patch_format\" in\n \tmbox)\n-\t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b -- \"$@\" > \"$dotest/last\" ||  {\n-\t\t\trm -fr \"$dotest\"\n-\t\t\texit 1\n-\t\t}\n+\t\tgit mailsplit -d\"$prec\" -o\"$dotest\" -b -- \"$@\" > \"$dotest/last\" || clean_abort\n \t\t;;\n \tstgit-series)\n \t\tif test $# -ne 1\n \t\tthen\n-\t\t\techo \"Only one StGIT patch series can be applied at once\"\n-\t\t\texit 1\n+\t\t\tclean_abort \"Only one StGIT patch series can be applied at once\"\n \t\tfi\n \t\tseries_dir=`dirname \"$1\"`\n \t\tseries_file=\"$1\"\n@@ -210,7 +215,7 @@ split_patches () {\n \t\t\tshift\n \t\t\t# remove the arg coming from the first-line comment\n \t\t\tshift\n-\t\t} < \"$series_file\"\n+\t\t} < \"$series_file\" || clean_abort\n \t\t# set the patch format appropriately\n \t\tpatch_format=stgit\n \t\t# now handle the actual StGIT patches\n@@ -239,18 +244,14 @@ split_patches () {\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\" || {\n-\t\t\t\techo \"Failed to import $patch_format patch $stgit\"\n-\t\t\t\texit 1\n-\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 \t*)\n-\t\techo \"Patch format $patch_format is not supported.\"\n-\t\texit 1\n+\t\tclean_abort \"Patch format $patch_format is not supported.\"\n \t\t;;\n \tesac\n }\n-- \n1.6.3.1.282.g9f93\n"},{"id":"115236","messageId":"20090602195608.6117@nanako3.lavabit.com","threadId":"19631","inReplyTo":"1243897841-8923-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCHv3 (resend) 0/4] git-am foreign patch support","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-06-02T10:56:08Z","receivedAt":"2009-06-02T10:56:08Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Giuseppe Bilotta <giuseppe.bilotta@gmail.com>:\n\n> Junio mentioned that he's ready to apply the series cleanly, so here's\n> a resend rebased on latest 'next' and without any 'bis' patches ;-)\n>\n> Giuseppe Bilotta (4):\n>   git-am foreign patch support: introduce patch_format\n>   git-am foreign patch support: autodetect some patch formats\n>   git-am foreign patch support: StGIT support\n>   git-am: refactor 'cleaning up and aborting'\n>\n>  git-am.sh |  133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n>  1 files changed, 129 insertions(+), 4 deletions(-)\n\nMay we have a summary of what's updated, compared to the version that has been in the \"pu\" branch?\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"115251","messageId":"7v4ouyhda4.fsf@alter.siamese.dyndns.org","threadId":"19631","inReplyTo":"20090602195608.6117@nanako3.lavabit.com","subject":"Re: [PATCHv3 (resend) 0/4] git-am foreign patch support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-02T15:21:39Z","receivedAt":"2009-06-02T15:21:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> writes:\n\n> Quoting Giuseppe Bilotta <giuseppe.bilotta@gmail.com>:\n>\n>> Junio mentioned that he's ready to apply the series cleanly, so here's\n>> a resend rebased on latest 'next' and without any 'bis' patches ;-)\n>>\n>> Giuseppe Bilotta (4):\n>>   git-am foreign patch support: introduce patch_format\n>>   git-am foreign patch support: autodetect some patch formats\n>>   git-am foreign patch support: StGIT support\n>>   git-am: refactor 'cleaning up and aborting'\n>>\n>>  git-am.sh |  133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n>>  1 files changed, 129 insertions(+), 4 deletions(-)\n>\n> May we have a summary of what's updated, compared to the version that has been in the \"pu\" branch?\n\nA good thing to ask, for two reasons, as (1) Giuseppe might not have known\nabout what were in 'pu', and (2) I _did_ fix up his earlier series when I\nqueued, and his \"resend\" loses them.\n\nI just compared what is in 'pu' with this resend, and the only changes I\nsaw was my fix-up, so I'll keep the previous ones.\n\nThanks.\n"}]}