summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 80d12c2)
raw | patch | inline | side by side (parent: 80d12c2)
author | Pieter de Bie <pdebie@ai.rug.nl> | |
Sun, 7 Sep 2008 23:05:41 +0000 (01:05 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 7 Sep 2008 23:15:49 +0000 (16:15 -0700) |
This outputs the current branch on which a commit was created, just for
reference. For example:
Created commit 6d42875 on master: Fix submodule invalid command error
This also reminds the committer when he is on a detached HEAD:
Created commit 02a7172 on detached HEAD: Also do this for 'git commit --amend'
Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reference. For example:
Created commit 6d42875 on master: Fix submodule invalid command error
This also reminds the committer when he is on a detached HEAD:
Created commit 02a7172 on detached HEAD: Also do this for 'git commit --amend'
Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index 8165bb3d31c6cdd92c83663c5dd081e564dcfc1e..f7b90604aa61c2cc77f154ccdfa4c0794c997c8f 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
return commitable ? 0 : 1;
}
+static char *get_commit_format_string(void)
+{
+ unsigned char sha[20];
+ const char *head = resolve_ref("HEAD", sha, 0, NULL);
+ struct strbuf buf = STRBUF_INIT;
+
+ strbuf_addstr(&buf, "format:%h");
+
+ /* Are we on a detached HEAD? */
+ if (!strcmp("HEAD", head))
+ strbuf_addstr(&buf, " on detached HEAD");
+ else if (!prefixcmp(head, "refs/heads/")) {
+ const char *cp;
+ strbuf_addstr(&buf, " on ");
+ for (cp = head + 11; *cp; cp++) {
+ if (*cp == '%')
+ strbuf_addstr(&buf, "%x25");
+ else
+ strbuf_addch(&buf, *cp);
+ }
+ }
+ strbuf_addstr(&buf, ": %s");
+
+ return strbuf_detach(&buf, NULL);
+}
+
static void print_summary(const char *prefix, const unsigned char *sha1)
{
struct rev_info rev;
struct commit *commit;
+ char *format = get_commit_format_string();
commit = lookup_commit(sha1);
if (!commit)
rev.verbose_header = 1;
rev.show_root_diff = 1;
- get_commit_format("format:%h: %s", &rev);
+ get_commit_format(format, &rev);
rev.always_show_header = 0;
rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = 100;
if (!log_tree_commit(&rev, commit)) {
struct strbuf buf = STRBUF_INIT;
- format_commit_message(commit, "%h: %s", &buf, DATE_NORMAL);
+ format_commit_message(commit, format + 7, &buf, DATE_NORMAL);
printf("%s\n", buf.buf);
strbuf_release(&buf);
}
+ free(format);
}
static int git_commit_config(const char *k, const char *v, void *cb)