• Junio C Hamano's avatar
    show-branch: fix segfault when showbranch.default exists · 3af1cae4
    Junio C Hamano authored
    When running "git show-branch" without any parameter in a repository that
    has showbranch.default defined, we used to rely on the fact that our
    handcrafted option parsing loop never looked at av[0].
    The array of default strings had the first real command line argument in
    default_arg[0], but the option parser wanted to look at the array starting
    at av[1], so we assigned the address of -1th element to av to force the
    loop start working from default_arg[0].
    This no longer worked since 57343652 (show-branch: migrate to parse-options
    API, 2009-05-21), as parse_options_start() saved the incoming &av[0] in
    its ctx->out and later in parse_options_end() it did memmove to ctx->out
    (with ctx->cpidx == 0), overwriting the memory before default_arg[] array.
    I am not sure if this is a bug in parse_options(), or a bug in the caller,
    and tonight I do not have enough concentration to figure out which.  In
    any case, this patch works the issue around.
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
t3202-show-branch-octopus.sh 1.3 KB