summaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-10-18 14:07:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-10-18 14:07:23 (GMT)
commitf4a75a416f62c0494e06cb42a11c7cc70ec9303e (patch)
treeb8318783753a6afd782d5447b8b4da8c02a670b3 /builtin-commit.c
parent46dc1b0e332612aa32c139007fa33f4b429de9d1 (diff)
parentb724fd094496625325dae009170445ef12862f96 (diff)
downloadgit-f4a75a416f62c0494e06cb42a11c7cc70ec9303e.zip
git-f4a75a416f62c0494e06cb42a11c7cc70ec9303e.tar.gz
git-f4a75a416f62c0494e06cb42a11c7cc70ec9303e.tar.bz2
Merge branch 'pb/commit-where'
* pb/commit-where: tutorial: update output of git commit reformat informational commit message git commit: Reformat output somewhat builtin-commit.c: show on which branch a commit was added
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index a2755dc..2c33af2 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -879,6 +879,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
{
struct rev_info rev;
struct commit *commit;
+ static const char *format = "format:%h: \"%s\"";
+ unsigned char junk_sha1[20];
+ const char *head = resolve_ref("HEAD", junk_sha1, 0, NULL);
commit = lookup_commit(sha1);
if (!commit)
@@ -896,18 +899,24 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
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;
rev.diffopt.break_opt = 0;
diff_setup_done(&rev.diffopt);
- printf("Created %scommit ", initial_commit ? "initial " : "");
+ printf("[%s%s]: created ",
+ !prefixcmp(head, "refs/heads/") ?
+ head + 11 :
+ !strcmp(head, "HEAD") ?
+ "detached HEAD" :
+ head,
+ initial_commit ? " (root-commit)" : "");
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);
}