o For what? E.g. you have tuned your post-script to send a notification on patches committed to the main branch. It is usefull when such notification sended as a reply on original message to follow already committed patches. o How to use? Just 'git-am' your message. To whatch a message ID in logs use '%M' in pretty format or 'full' format. --- builtin-commit-tree.c | 2 ++ builtin-mailinfo.c | 5 ++++- git-am.sh | 3 ++- pretty.c | 12 ++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index 6610d18..b396ec4 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -100,6 +100,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) /* Person/date information */ strbuf_addf(&buffer, "author %s\n", git_author_info(IDENT_ERROR_ON_NO_NAME)); strbuf_addf(&buffer, "committer %s\n", git_committer_info(IDENT_ERROR_ON_NO_NAME)); + if (getenv("GIT_MESSAGE_ID") != NULL) + strbuf_addf(&buffer, "message %s\n", getenv("GIT_MESSAGE_ID")); if (!encoding_is_utf8) strbuf_addf(&buffer, "encoding %s\n", git_commit_encoding); strbuf_addch(&buffer, '\n'); diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 11f154b..f800d86 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -289,7 +289,7 @@ static void cleanup_space(char *buf) static void decode_header(char *it, unsigned itsize); static const char *header[MAX_HDR_PARSED] = { - "From","Subject","Date", + "From","Subject","Date","Message-ID" }; static int check_header(char *line, unsigned linesize, char **hdr_data, int overwrite) @@ -905,6 +905,9 @@ static void handle_info(void) handle_from(hdr); fprintf(fout, "Author: %s\n", name); fprintf(fout, "Email: %s\n", email); + } else if (!memcmp(header[i], "Message-ID", 10)) { + cleanup_space(hdr); + fprintf(fout, "%s: %s\n", header[i], hdr); } else { cleanup_space(hdr); fprintf(fout, "%s: %s\n", header[i], hdr); diff --git a/git-am.sh b/git-am.sh index ac5c388..ba22bf8 100755 --- a/git-am.sh +++ b/git-am.sh @@ -338,6 +338,7 @@ do GIT_AUTHOR_NAME="$(sed -n '/^Author/ s/Author: //p' "$dotest/info")" GIT_AUTHOR_EMAIL="$(sed -n '/^Email/ s/Email: //p' "$dotest/info")" GIT_AUTHOR_DATE="$(sed -n '/^Date/ s/Date: //p' "$dotest/info")" + GIT_MESSAGE_ID="$(sed -n '/^Message-ID/ s/Message-ID: //p' "$dotest/info")" if test -z "$GIT_AUTHOR_EMAIL" then @@ -345,7 +346,7 @@ do stop_here $this fi - export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE GIT_MESSAGE_ID SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")" case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac diff --git a/pretty.c b/pretty.c index 16bfb86..076718c 100644 --- a/pretty.c +++ b/pretty.c @@ -385,6 +385,7 @@ struct format_commit_context { struct chunk subject; struct chunk author; struct chunk committer; + struct chunk message; struct chunk encoding; size_t body_off; @@ -438,6 +439,9 @@ static void parse_commit_header(struct format_commit_context *context) } else if (!prefixcmp(msg + i, "committer ")) { context->committer.off = i + 10; context->committer.len = eol - i - 10; + } else if (!prefixcmp(msg + i, "message ")) { + context->message.off = i + 8; + context->message.len = eol - i - 8; } else if (!prefixcmp(msg + i, "encoding ")) { context->encoding.off = i + 9; context->encoding.len = eol - i - 9; @@ -547,6 +551,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder, case 'c': /* committer ... */ return format_person_part(sb, placeholder[1], msg + c->committer.off, c->committer.len); + case 'M': /* message */ + strbuf_add(sb, msg + c->message.off, c->message.len); + return 1; case 'e': /* encoding */ strbuf_add(sb, msg + c->encoding.off, c->encoding.len); return 1; @@ -627,6 +634,11 @@ static void pp_header(enum cmit_fmt fmt, strbuf_grow(sb, linelen + 80); pp_user_info("Commit", fmt, sb, line + 10, dmode, encoding); } + if (!memcmp(line, "message ", 8) && + (fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER)) { + strbuf_grow(sb, linelen + 80); + pp_user_info("Message-ID", fmt, sb, line + 8, dmode, encoding); + } } } -- 1.5.5.rc0.22.ga384d.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html