]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-branch.c
Merge branch 'js/branch-track'
[thirdparty/git.git] / builtin-branch.c
index 32eaf0d1e4e9fd8e5ca720852e9ae5ca122bdd44..a7844454a291d4ea1c126302d1f499497f35929a 100644 (file)
@@ -30,7 +30,7 @@ static const char * const builtin_branch_usage[] = {
 static const char *head;
 static unsigned char head_sha1[20];
 
-static int branch_use_color;
+static int branch_use_color = -1;
 static char branch_colors[][COLOR_MAXLEN] = {
        "\033[m",       /* reset */
        "",             /* PLAIN (normal) */
@@ -69,15 +69,17 @@ static int git_branch_config(const char *var, const char *value)
        }
        if (!prefixcmp(var, "color.branch.")) {
                int slot = parse_branch_color_slot(var, 13);
+               if (!value)
+                       return config_error_nonbool(var);
                color_parse(value, var, branch_colors[slot]);
                return 0;
        }
-       return git_default_config(var, value);
+       return git_color_default_config(var, value);
 }
 
 static const char *branch_get_color(enum color_branch ix)
 {
-       if (branch_use_color)
+       if (branch_use_color > 0)
                return branch_colors[ix];
        return "";
 }
@@ -448,6 +450,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        };
 
        git_config(git_branch_config);
+
+       if (branch_use_color == -1)
+               branch_use_color = git_use_color_default;
+
        track = git_branch_track;
        argc = parse_options(argc, argv, options, builtin_branch_usage, 0);
        if (!!delete + !!rename + !!force_create > 1)