diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2022-08-19 18:03:59 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-19 11:13:14 -0700 |
commit | dc9f98832b849ee05b84bad1a55f5e04b82d0520 (patch) | |
tree | ad455c8785f829db8cfd2038657d7783cf72f129 /parse-options.c | |
parent | a9126b92a2adddb58522a342cdbaf0aec4d879bf (diff) | |
download | git-dc9f98832b849ee05b84bad1a55f5e04b82d0520.tar.gz |
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>
Diffstat (limited to 'parse-options.c')
-rw-r--r-- | parse-options.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/parse-options.c b/parse-options.c index a0a2cf98fa..8748f88e6f 100644 --- a/parse-options.c +++ b/parse-options.c @@ -620,7 +620,8 @@ static int show_gitcomp(const struct option *opts, int show_all) suffix = "="; if (starts_with(opts->long_name, "no-")) nr_noopts++; - printf(" --%s%s", opts->long_name, suffix); + printf("%s--%s%s", opts == original_opts ? "" : " ", + opts->long_name, suffix); } show_negated_gitcomp(original_opts, show_all, -1); show_negated_gitcomp(original_opts, show_all, nr_noopts); |