parse-options: drop leading space from '--git-completion-helper' output

The output of 'git <cmd> --git-completion-helper' always starts with a space, e.g.: $ git config --git-completion-helper --global --system --local [...] This doesn't matter for the completion script, because field splitting discards that space anyway. However, later patches in this series will teach parse-options to handle subcommands, and subcommands will be included in the completion helper output as well. This will make the loop printing options (and subcommands) a tad more complex, so I wanted to test the result. The test would have to account for the presence of that leading space, which bugged my OCD, so let's get rid of it. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Aug 19, 2022 at 18:03 UTC dc9f98832b849ee05b84bad1a55f5e04b82d0520
1 file changed +2 -1
parse-options.c
+2 -1
@@ -620,7 +620,8 @@ static int show_gitcomp(const struct option *opts, int show_all)
620 suffix = "=";
621 if (starts_with(opts->long_name, "no-"))
622 nr_noopts++;
623 - printf(" --%s%s", opts->long_name, suffix);
623 + printf("%s--%s%s", opts == original_opts ? "" : " ",
624 + opts->long_name, suffix);
625 }
626 show_negated_gitcomp(original_opts, show_all, -1);
627 show_negated_gitcomp(original_opts, show_all, nr_noopts);