summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-10-14 17:50:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-10-14 17:50:07 (GMT)
commit145c590df8131abe510adde677eb3121cf52d31e (patch)
tree1bec212671aca326a5f966df97e159bc25ccdb79 /builtin/commit.c
parent63434da0b4966894b5b812965cb3ada3d4101d6c (diff)
parente3f1da982e4f14e7146964cb25a5011a3f41e84a (diff)
downloadgit-145c590df8131abe510adde677eb3121cf52d31e.zip
git-145c590df8131abe510adde677eb3121cf52d31e.tar.gz
git-145c590df8131abe510adde677eb3121cf52d31e.tar.bz2
Merge branch 'rs/more-uses-of-skip-prefix'
* rs/more-uses-of-skip-prefix: use skip_prefix() to avoid more magic numbers
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index c230018..81dc622 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1295,6 +1295,7 @@ static int parse_status_slot(const char *var, int offset)
static int git_status_config(const char *k, const char *v, void *cb)
{
struct wt_status *s = cb;
+ const char *slot_name;
if (starts_with(k, "column."))
return git_column_config(k, v, "status", &s->colopts);
@@ -1324,8 +1325,9 @@ static int git_status_config(const char *k, const char *v, void *cb)
s->display_comment_prefix = git_config_bool(k, v);
return 0;
}
- if (starts_with(k, "status.color.") || starts_with(k, "color.status.")) {
- int slot = parse_status_slot(k, 13);
+ if (skip_prefix(k, "status.color.", &slot_name) ||
+ skip_prefix(k, "color.status.", &slot_name)) {
+ int slot = parse_status_slot(k, slot_name - k);
if (slot < 0)
return 0;
if (!v)
@@ -1514,13 +1516,11 @@ static void print_summary(const char *prefix, const unsigned char *sha1,
diff_setup_done(&rev.diffopt);
head = resolve_ref_unsafe("HEAD", junk_sha1, 0, NULL);
- printf("[%s%s ",
- starts_with(head, "refs/heads/") ?
- head + 11 :
- !strcmp(head, "HEAD") ?
- _("detached HEAD") :
- head,
- initial_commit ? _(" (root-commit)") : "");
+ if (!strcmp(head, "HEAD"))
+ head = _("detached HEAD");
+ else
+ skip_prefix(head, "refs/heads/", &head);
+ printf("[%s%s ", head, initial_commit ? _(" (root-commit)") : "");
if (!log_tree_commit(&rev, commit)) {
rev.always_show_header = 1;