From: Junio C Hamano Date: Sun, 4 Oct 2009 21:48:51 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.6.5-rc3~6 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a7aebb9d00332364411e85c703cc25dc0580f2d4?ds=inline;hp=-c Merge branch 'maint' * maint: show-branch: fix segfault when showbranch.default exists --- a7aebb9d00332364411e85c703cc25dc0580f2d4 diff --combined builtin-show-branch.c index 3510a86e38,baec9ed56f..be95930b78 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@@ -6,8 -6,8 +6,8 @@@ #include "parse-options.h" static const char* show_branch_usage[] = { - "git show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base] [--topics] [--color] [...]", - "--reflog[=n[,b]] [--list] [--color] ", + "git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color | --no-color] [--sparse] [--more= | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [ | ]...", + "git show-branch (-g|--reflog)[=[,]] [--list] []", NULL }; @@@ -565,7 -565,15 +565,15 @@@ static int git_show_branch_config(cons 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); } @@@ -665,7 -673,7 +673,7 @@@ int cmd_show_branch(int ac, const char OPT_BOOLEAN(0, "sha1-name", &sha1_name, "name commits with their object names"), OPT_BOOLEAN(0, "merge-base", &merge_base, - "act like git merge-base -a"), + "show possible merge bases"), OPT_BOOLEAN(0, "independent", &independent, "show refs unreachable from any other ref"), OPT_BOOLEAN(0, "topo-order", &lifo, @@@ -692,8 -700,8 +700,8 @@@ /* 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,