{"thread":{"id":"37042","subject":"[PATCH v4] git-am: add option to extract email Message-Id: tag into commit log","startedAt":"2014-07-02T14:51:13Z","lastAt":"2014-07-02T16:15:29Z","messageCount":3,"participants":["Avi Kivity","Torsten Bögershausen"],"isPatch":true,"patchVersion":4,"patchTotal":null},"messages":[{"id":"245298","messageId":"1404312673-11836-1-git-send-email-avi@cloudius-systems.com","threadId":"37042","inReplyTo":null,"subject":"[PATCH v4] git-am: add option to extract email Message-Id: tag into commit log","fromName":"Avi Kivity","fromEmail":"avi@cloudius-systems.com","sentAt":"2014-07-02T14:51:13Z","receivedAt":"2014-07-02T14:51:13Z","isPatch":true,"sender":{"key":"avi@cloudius-systems.com","avatar":null},"body":"Some workflows prefer to track exactly which email message was used to\ngenerate a commit.  This can be used, for example, to generate an\nautomated acknowledgement when a patch is committed as a response to\nthe patch email, or as a reference to the thread which introduced the\npatch.\n\nSupport this by adding a --message-id option (abbreviated as -m) to\ngit-am, which will then extract the message ID and append it to the\nemail commit log.\n\nSigned-off-by: Avi Kivity <avi@cloudius-systems.com>\n---\n\nv4: adjust coding style\n    recover message_id variable after a resumed git-am\n    use sane_grep\n    drop unneeded grep error handling\n\nv3: remove bashism and unneeded quoting\n\nv2: adjust to pass test suite (t5100)\n\n Documentation/git-am.txt |  6 ++++++\n builtin/mailinfo.c       |  2 +-\n git-am.sh                | 14 +++++++++++++-\n t/t5100/info0004         |  1 +\n t/t5100/info0005         |  1 +\n t/t5100/info0012         |  1 +\n 6 files changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-am.txt b/Documentation/git-am.txt\nindex 9adce37..8a251a1 100644\n--- a/Documentation/git-am.txt\n+++ b/Documentation/git-am.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n \t [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]\n \t [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]\n \t [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]\n+\t [--message-id]\n \t [(<mbox> | <Maildir>)...]\n 'git am' (--continue | --skip | --abort)\n \n@@ -121,6 +122,11 @@ default.   You can use `--no-utf8` to override this.\n \tuser to lie about the author date by using the same\n \tvalue as the committer date.\n \n+-m::\n+--message-id::\n+\tExtract the Message-Id: header from the e-mail and\n+\tappend it to the commit message's tag stanza.\n+\n --skip::\n \tSkip the current patch.  This is only meaningful when\n \trestarting an aborted patch.\ndiff --git a/builtin/mailinfo.c b/builtin/mailinfo.c\nindex cf11c8d..f1e1fed 100644\n--- a/builtin/mailinfo.c\n+++ b/builtin/mailinfo.c\n@@ -278,7 +278,7 @@ static void cleanup_space(struct strbuf *sb)\n \n static void decode_header(struct strbuf *line);\n static const char *header[MAX_HDR_PARSED] = {\n-\t\"From\",\"Subject\",\"Date\",\n+\t\"From\",\"Subject\",\"Date\",\"Message-Id\"\n };\n \n static inline int cmp_header(const struct strbuf *line, const char *hdr)\ndiff --git a/git-am.sh b/git-am.sh\nindex ee61a77..fd0181f 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -39,6 +39,7 @@ committer-date-is-author-date    lie about committer date\n ignore-date     use current timestamp for author date\n rerere-autoupdate update the index with reused conflict resolution if possible\n S,gpg-sign?     GPG-sign commits\n+m,message-id    copy the Message-Id: header to the commit's tag stanza\n rebasing*       (internal use for git-rebase)\"\n \n . git-sh-setup\n@@ -371,7 +372,7 @@ split_patches () {\n prec=4\n dotest=\"$GIT_DIR/rebase-apply\"\n sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=\n-resolvemsg= resume= scissors= no_inbody_headers=\n+resolvemsg= resume= scissors= no_inbody_headers= message_id=\n git_apply_opt=\n committer_date_is_author_date=\n ignore_date=\n@@ -442,6 +443,8 @@ it will be removed. Please do not use it anymore.\"\n \t\tgpg_sign_opt=-S ;;\n \t--gpg-sign=*)\n \t\tgpg_sign_opt=\"-S${1#--gpg-sign=}\" ;;\n+\t-m|--message-id)\n+\t\tmessage_id=t ;;\n \t--)\n \t\tshift; break ;;\n \t*)\n@@ -565,6 +568,7 @@ Use \\\"git am --abort\\\" to remove it.\")\"\n \techo \" $git_apply_opt\" >\"$dotest/apply-opt\"\n \techo \"$threeway\" >\"$dotest/threeway\"\n \techo \"$sign\" >\"$dotest/sign\"\n+\techo \"$message_id\" >\"$dotest/message-id\"\n \techo \"$utf8\" >\"$dotest/utf8\"\n \techo \"$keep\" >\"$dotest/keep\"\n \techo \"$scissors\" >\"$dotest/scissors\"\n@@ -651,6 +655,10 @@ then\n else\n \tSIGNOFF=\n fi\n+if test \"$(cat \"$dotest/message-id\")\" = t\n+then\n+\tmessage_id=t\n+fi\n \n last=$(cat \"$dotest/last\")\n this=$(cat \"$dotest/next\")\n@@ -757,6 +765,10 @@ To restore the original branch and stop patching run \\\"\\$cmdline --abort\\\".\"\n \t\tthen\n \t\t\tcat \"$dotest/msg-clean\"\n \t\tfi\n+\t\tif test t = \"$message_id\"\n+\t\tthen\n+\t\t\tsane_grep ^Message-Id: \"$dotest/info\"\n+\t\tfi\n \t\tif test '' != \"$ADD_SIGNOFF\"\n \t\tthen\n \t\t\techo \"$ADD_SIGNOFF\"\ndiff --git a/t/t5100/info0004 b/t/t5100/info0004\nindex 616c309..f7e2983 100644\n--- a/t/t5100/info0004\n+++ b/t/t5100/info0004\n@@ -2,4 +2,5 @@ Author: YOSHIFUJI Hideaki / 吉藤英明\n Email: yoshfuji@linux-ipv6.org\n Subject: GIT: Try all addresses for given remote name\n Date: Thu, 21 Jul 2005 09:10:36 -0400 (EDT)\n+Message-Id: <20050721.091036.01119516.yoshfuji@linux-ipv6.org>\n \ndiff --git a/t/t5100/info0005 b/t/t5100/info0005\nindex 46a46fc..592388f 100644\n--- a/t/t5100/info0005\n+++ b/t/t5100/info0005\n@@ -2,4 +2,5 @@ Author: David Kågedal\n Email: davidk@lysator.liu.se\n Subject: Fixed two bugs in git-cvsimport-script.\n Date: Mon, 15 Aug 2005 20:18:25 +0200\n+Message-Id: <u5tacjjdpxq.fsf@lysator.liu.se>\n \ndiff --git a/t/t5100/info0012 b/t/t5100/info0012\nindex ac1216f..b5d89a1 100644\n--- a/t/t5100/info0012\n+++ b/t/t5100/info0012\n@@ -2,4 +2,5 @@ Author: Dmitriy Blinov\n Email: bda@mnsspb.ru\n Subject: Изменён список пакетов необходимых для сборки\n Date: Wed, 12 Nov 2008 17:54:41 +0300\n+Message-Id: <1226501681-24923-1-git-send-email-bda@mnsspb.ru>\n \n-- \n1.9.3\n"},{"id":"245300","messageId":"53B41F28.8040205@web.de","threadId":"37042","inReplyTo":"1404312673-11836-1-git-send-email-avi@cloudius-systems.com","subject":"Re: [PATCH v4] git-am: add option to extract email Message-Id: tag into commit log","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-07-02T15:03:04Z","receivedAt":"2014-07-02T15:03:04Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"> diff --git a/git-am.sh b/git-am.sh\n> index ee61a77..fd0181f 100755\n> --- a/git-am.sh\n> +++ b/git-am.sh\n> @@ -39,6 +39,7 @@ committer-date-is-author-date    lie about committer date\n>  ignore-date     use current timestamp for author date\n>  rerere-autoupdate update the index with reused conflict resolution if possible\n>  S,gpg-sign?     GPG-sign commits\n> +m,message-id    copy the Message-Id: header to the commit's tag stanza\n>  rebasing*       (internal use for git-rebase)\"\n>  \n>  . git-sh-setup\n> @@ -371,7 +372,7 @@ split_patches () {\n>  prec=4\n>  dotest=\"$GIT_DIR/rebase-apply\"\n>  sign= utf8=t keep= keepcr= skip= interactive= resolved= rebasing= abort=\n> -resolvemsg= resume= scissors= no_inbody_headers=\n> +resolvemsg= resume= scissors= no_inbody_headers= message_id=\n>  git_apply_opt=\n>  committer_date_is_author_date=\n>  ignore_date=\n> @@ -442,6 +443,8 @@ it will be removed. Please do not use it anymore.\"\n>  \t\tgpg_sign_opt=-S ;;\n>  \t--gpg-sign=*)\n>  \t\tgpg_sign_opt=\"-S${1#--gpg-sign=}\" ;;\n> +\t-m|--message-id)\n> +\t\tmessage_id=t ;;\n>  \t--)\n>  \t\tshift; break ;;\n>  \t*)\n> @@ -565,6 +568,7 @@ Use \\\"git am --abort\\\" to remove it.\")\"\n>  \techo \" $git_apply_opt\" >\"$dotest/apply-opt\"\n>  \techo \"$threeway\" >\"$dotest/threeway\"\n>  \techo \"$sign\" >\"$dotest/sign\"\n> +\techo \"$message_id\" >\"$dotest/message-id\"\n>  \techo \"$utf8\" >\"$dotest/utf8\"\n>  \techo \"$keep\" >\"$dotest/keep\"\n>  \techo \"$scissors\" >\"$dotest/scissors\"\n> @@ -651,6 +655,10 @@ then\n>  else\n>  \tSIGNOFF=\n>  fi\n> +if test \"$(cat \"$dotest/message-id\")\" = t\nDoes the usage of '\"' inside of '\"' look good, or can we write like this:\nif test $(cat \"$dotest/message-id\") = t\n"},{"id":"245303","messageId":"53B43021.9090506@cloudius-systems.com","threadId":"37042","inReplyTo":"53B41F28.8040205@web.de","subject":"Re: [PATCH v4] git-am: add option to extract email Message-Id: tag into commit log","fromName":"Avi Kivity","fromEmail":"avi@cloudius-systems.com","sentAt":"2014-07-02T16:15:29Z","receivedAt":"2014-07-02T16:15:29Z","isPatch":true,"sender":{"key":"avi@cloudius-systems.com","avatar":null},"body":"\nOn 07/02/2014 06:03 PM, Torsten Bögershausen wrote:\n>> @@ -565,6 +568,7 @@ Use \\\"git am --abort\\\" to remove it.\")\"\n>>   \techo \" $git_apply_opt\" >\"$dotest/apply-opt\"\n>>   \techo \"$threeway\" >\"$dotest/threeway\"\n>>   \techo \"$sign\" >\"$dotest/sign\"\n>> +\techo \"$message_id\" >\"$dotest/message-id\"\n>>   \techo \"$utf8\" >\"$dotest/utf8\"\n>>   \techo \"$keep\" >\"$dotest/keep\"\n>>   \techo \"$scissors\" >\"$dotest/scissors\"\n>> @@ -651,6 +655,10 @@ then\n>>   else\n>>   \tSIGNOFF=\n>>   fi\n>> +if test \"$(cat \"$dotest/message-id\")\" = t\n> Does the usage of '\"' inside of '\"' look good, or can we write like this:\n> if test $(cat \"$dotest/message-id\") = t\n\nWith your change, it will fail if the file is missing or empty.\n\nComplex shell scripts cannot be made to look good.  If that's a \nrequirement then the script should be rewritten in a reasonable language.\n"}]}