]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-show-branch.c
Merge branch 'jc/maint-1.6.4-show-branch-default' into maint
[thirdparty/git.git] / builtin-show-branch.c
index 01bea3b583b53f4930a1ab17d64b1b714f58099c..baec9ed56f4098183445b85cdd1b2789d487d6fe 100644 (file)
@@ -565,7 +565,15 @@ static int git_show_branch_config(const char *var, const char *value, void *cb)
        if (!strcmp(var, "showbranch.default")) {
                if (!value)
                        return config_error_nonbool(var);
-               if (default_alloc <= default_num + 1) {
+               /*
+                * default_arg is now passed to parse_options(), so we need to
+                * mimick the real argv a bit better.
+                */
+               if (!default_num) {
+                       default_alloc = 20;
+                       default_arg = xcalloc(default_alloc, sizeof(*default_arg));
+                       default_arg[default_num++] = "show-branch";
+               } else if (default_alloc <= default_num + 1) {
                        default_alloc = default_alloc * 3 / 2 + 20;
                        default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc);
                }
@@ -692,8 +700,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 
        /* If nothing is specified, try the default first */
        if (ac == 1 && default_num) {
-               ac = default_num + 1;
-               av = default_arg - 1; /* ick; we would not address av[0] */
+               ac = default_num;
+               av = default_arg;
        }
 
        ac = parse_options(ac, av, prefix, builtin_show_branch_options,