{"thread":{"id":"37038","subject":"[PATCH] git-am: add option to extract email Message-Id: tag into commit log","startedAt":"2014-07-02T08:24:01Z","lastAt":"2014-07-02T08:24:01Z","messageCount":1,"participants":["Avi Kivity"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"245284","messageId":"1404289441-6117-1-git-send-email-avi@cloudius-systems.com","threadId":"37038","inReplyTo":null,"subject":"[PATCH] git-am: add option to extract email Message-Id: tag into commit log","fromName":"Avi Kivity","fromEmail":"avi@cloudius-systems.com","sentAt":"2014-07-02T08:24:01Z","receivedAt":"2014-07-02T08:24:01Z","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 Documentation/git-am.txt |  6 ++++++\n builtin/mailinfo.c       |  2 +-\n git-am.sh                | 10 +++++++++-\n 3 files changed, 16 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..22799ff 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\"\n+\t\tfi\n \t\tif test '' != \"$ADD_SIGNOFF\"\n \t\tthen\n \t\t\techo \"$ADD_SIGNOFF\"\n-- \n1.9.3\n"}]}