]> granicus.if.org Git - git/commitdiff
Merge branch 'jn/parse-config-slot'
authorJunio C Hamano <gitster@pobox.com>
Mon, 20 Oct 2014 19:23:48 +0000 (12:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Oct 2014 19:23:48 +0000 (12:23 -0700)
Code cleanup.

* jn/parse-config-slot:
  color_parse: do not mention variable name in error message
  pass config slots as pointers instead of offsets

1  2 
builtin/branch.c
builtin/clean.c
builtin/commit.c
builtin/config.c
builtin/for-each-ref.c
builtin/log.c
diff.c
log-tree.c
log-tree.h
pretty.c

index 67850975e7bebbf122ec961a527497c40c2c3f27,0a8ed9d22a410d51c44c3f93ade8bf746f071331..19a93a14d7dd04c2150ff43a8c0751d4a09baabb
@@@ -89,8 -87,8 +89,8 @@@ static int git_branch_config(const cha
                branch_use_color = git_config_colorbool(var, value);
                return 0;
        }
 -      if (starts_with(var, "color.branch.")) {
 -              int slot = parse_branch_color_slot(var + 13);
 +      if (skip_prefix(var, "color.branch.", &slot_name)) {
-               int slot = parse_branch_color_slot(var, slot_name - var);
++              int slot = parse_branch_color_slot(slot_name);
                if (slot < 0)
                        return 0;
                if (!value)
diff --cc builtin/clean.c
Simple merge
index 81dc622a3b72040daca199f05d0a3322f316e6f6,8dab44d93362553f4a9a55b66ba1d4a947795afd..60d35d0408c4900dfd86b24c86824a1e90da1f41
@@@ -1325,9 -1289,8 +1324,9 @@@ static int git_status_config(const cha
                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);
++              int slot = parse_status_slot(slot_name);
                if (slot < 0)
                        return 0;
                if (!v)
Simple merge
Simple merge
diff --cc builtin/log.c
index 1202eba8b65c019662c5f6b82c13af947bd4d41c,4c5fc4bff5b955f712024a935b8b804fd7d5e363..68d5d30035442a1d12cf0fbf8a10dca0df2711be
@@@ -390,8 -388,8 +390,8 @@@ static int git_log_config(const char *v
                default_show_root = git_config_bool(var, value);
                return 0;
        }
 -      if (starts_with(var, "color.decorate."))
 -              return parse_decorate_color_config(var, var + 15, value);
 +      if (skip_prefix(var, "color.decorate.", &slot_name))
-               return parse_decorate_color_config(var, slot_name - var, value);
++              return parse_decorate_color_config(var, slot_name, value);
        if (!strcmp(var, "log.mailmap")) {
                use_mailmap_config = git_config_bool(var, value);
                return 0;
diff --cc diff.c
Simple merge
diff --cc log-tree.c
Simple merge
diff --cc log-tree.h
Simple merge
diff --cc pretty.c
index a181ac66875a158514bba48a21911adf9c5cd8be,6182ca9aed79503a4c24ed267b8cf69673cac16b..9d34d02db11bd6761d48484327fbc6d1704ad555
+++ b/pretty.c
@@@ -960,13 -974,13 +960,12 @@@ static size_t parse_color(struct strbu
  
                if (!end)
                        return 0;
 -              if (starts_with(begin, "auto,")) {
 +              if (skip_prefix(begin, "auto,", &begin)) {
                        if (!want_color(c->pretty_ctx->color))
                                return end - placeholder + 1;
 -                      begin += 5;
                }
-               color_parse_mem(begin,
-                               end - begin,
-                               "--pretty format", color);
+               if (color_parse_mem(begin, end - begin, color) < 0)
+                       die(_("unable to parse --pretty format"));
                strbuf_addstr(sb, color);
                return end - placeholder + 1;
        }