summaryrefslogtreecommitdiff
path: root/builtin-show-branch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-10-04 14:48:51 -0700
committerJunio C Hamano <gitster@pobox.com>2009-10-04 14:48:51 -0700
commita7aebb9d00332364411e85c703cc25dc0580f2d4 (patch)
treec1930a07e087ae511025391a012a734c98a4b8a6 /builtin-show-branch.c
parentdbc1b1f71052c084a84b5c395e1cb4b5ae526fcb (diff)
parent04ce83e2b9a1f1512d3d0c873e8f13d06761620c (diff)
downloadgit-a7aebb9d00332364411e85c703cc25dc0580f2d4.tar.gz
Merge branch 'maint'
* maint: show-branch: fix segfault when showbranch.default exists
Diffstat (limited to 'builtin-show-branch.c')
-rw-r--r--builtin-show-branch.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 3510a86e38..be95930b78 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -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,