summaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorAndreas Ericsson <ae@op5.se>2008-09-30 09:52:50 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2008-09-30 22:16:28 (GMT)
commit72c69ebc035efe08aef03866184aa9b344814d93 (patch)
tree636835a49d191f98bf894e6701cd7f24120130f2 /builtin-commit.c
parente502f9e7e6ceb8dfbdb94e2675355847740fc28f (diff)
downloadgit-72c69ebc035efe08aef03866184aa9b344814d93.zip
git-72c69ebc035efe08aef03866184aa9b344814d93.tar.gz
git-72c69ebc035efe08aef03866184aa9b344814d93.tar.bz2
git commit: Reformat output somewhat
Previously, we used to print something along the lines of Created commit abc9056 on master: Snib the sprock but that output was sometimes confusing, as many projects use the "subsystem: message" style of commit subjects (just like this commit message does). When such improvements are done on topic-branches, it's not uncommon to name the topic-branch the same as the subsystem, leading to output like this: Created commit abc9056 on i386: i386: Snib the sprock which doesn't look very nice and can be highly confusing. This patch alters the format so that the noise-word "commit" is dropped except when it makes the output read better and the commit subject is put inside parentheses. We also emphasize the detached case so that users do not overlook it in case the commit subject is long enough to extend to the next line. The end result looks thusly: normal case Created abc9056 (i386: Snib the sprock) on i386 detached head Created DETACHED commit abc9056 (i386: Snib the sprock) While we're at it, we rename "initial commit" to "root-commit" to align it with the argument to 'git log', producing this: initial commit Created root-commit abc9056 (i386: Snib the sprock) on i386 Documentation/gittutorial-2.txt is updated accordingly so that new users recognize what they're looking at. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index f7b9060..4f0745f 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -884,12 +884,11 @@ static char *get_commit_format_string(void)
const char *head = resolve_ref("HEAD", sha, 0, NULL);
struct strbuf buf = STRBUF_INIT;
- strbuf_addstr(&buf, "format:%h");
+ /* use shouty-caps if we're on detached HEAD */
+ strbuf_addf(&buf, "format:%s", strcmp("HEAD", head) ? "" : "DETACHED commit");
+ strbuf_addstr(&buf, "%h (%s)");
- /* Are we on a detached HEAD? */
- if (!strcmp("HEAD", head))
- strbuf_addstr(&buf, " on detached HEAD");
- else if (!prefixcmp(head, "refs/heads/")) {
+ if (!prefixcmp(head, "refs/heads/")) {
const char *cp;
strbuf_addstr(&buf, " on ");
for (cp = head + 11; *cp; cp++) {
@@ -899,7 +898,6 @@ static char *get_commit_format_string(void)
strbuf_addch(&buf, *cp);
}
}
- strbuf_addstr(&buf, ": %s");
return strbuf_detach(&buf, NULL);
}
@@ -933,7 +931,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
rev.diffopt.break_opt = 0;
diff_setup_done(&rev.diffopt);
- printf("Created %scommit ", initial_commit ? "initial " : "");
+ printf("Created %s", initial_commit ? "root-commit " : "");
if (!log_tree_commit(&rev, commit)) {
struct strbuf buf = STRBUF_INIT;