@@ -241,6 +241,7 @@ endif::git-rev-list[]
'%gE':: reflog identity email (respecting .mailmap, see
linkgit:git-shortlog[1] or linkgit:git-blame[1])
'%gs':: reflog subject
+'%Xb':: branchname in which commit was done
'%(trailers[:options])':: display the trailers of the body as
interpreted by
linkgit:git-interpret-trailers[1]. The
@@ -1425,6 +1425,9 @@ int commit_tree_extended(const char *msg, size_t msg_len,
int result;
int encoding_is_utf8;
struct strbuf buffer;
+ const char *branch = "Unknown";
+ int flags;
+ const char *lbranch =resolve_ref_unsafe("HEAD",0,NULL,&flags);
assert_oid_type(tree, OBJ_TREE);
@@ -1453,6 +1456,14 @@ int commit_tree_extended(const char *msg, size_t msg_len,
author = git_author_info(IDENT_STRICT);
strbuf_addf(&buffer, "author %s\n", author);
strbuf_addf(&buffer, "committer %s\n", git_committer_info(IDENT_STRICT));
+ if (lbranch) {
+ skip_prefix(lbranch,"refs/heads/",&branch);
+ strbuf_addf(&buffer, "branch %s\n", branch);
+ }
+ else {
+ strbuf_addf(&buffer, "branch Unknown\n");
+ }
+
if (!encoding_is_utf8)
strbuf_addf(&buffer, "encoding %s\n", git_commit_encoding);
@@ -804,6 +804,7 @@ struct format_commit_context {
/* The following ones are relative to the result struct strbuf. */
size_t wrap_start;
+ char *branch;
};
static void parse_commit_header(struct format_commit_context *context)
@@ -1367,6 +1368,20 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
return 1;
}
+
+ /* Now add extra header info */
+ if (placeholder[0] == 'X') {
+ switch (placeholder[1]) {
+ case 'b': /* branch ... */
+ c->branch = get_header(msg,"branch");
+ if (c->branch)
+ strbuf_addstr(sb, c->branch);
+ free(c->branch);
+ return 2;
+ }
+ }
+
+
/* Now we need to parse the commit message. */
if (!c->commit_message_parsed)
parse_commit_message(c);