{"thread":{"id":"37040","subject":"[PATCH v3] git-am: add option to extract email Message-Id: tag into commit log","startedAt":"2014-07-02T13:53:22Z","lastAt":"2014-07-02T13:53:22Z","messageCount":1,"participants":["Avi Kivity"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"245291","messageId":"1404309202-10438-1-git-send-email-avi@cloudius-systems.com","threadId":"37040","inReplyTo":null,"subject":"[PATCH v3] git-am: add option to extract email Message-Id: tag into commit log","fromName":"Avi Kivity","fromEmail":"avi@cloudius-systems.com","sentAt":"2014-07-02T13:53:22Z","receivedAt":"2014-07-02T13:53:22Z","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\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                | 10 +++++++++-\n t/t5100/info0004         |  1 +\n t/t5100/info0005         |  1 +\n t/t5100/info0012         |  1 +\n 6 files changed, 19 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..9fae315 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@@ -757,6 +761,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\tgrep ^Message-Id: \"$dotest/info\" || true\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"}]}