From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/3] parse-options: fix completion format when first option is skipped
Date: Fri, 2 Oct 2026 09:19:43 +0200 [thread overview]
Message-ID: <ar9bDza3ImB71AIN@pks.im> (raw)
In-Reply-To: <xmqqik3l5njz.fsf@gitster.g>
On Thu, Oct 01, 2026 at 10:38:08AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
>
> > The "--git-completion-helper" option can be passed to any command or
> > subcommand that uses the parse-options interface. The output it
> > generates is a space-separated list of subcommands or options understood
> > by the command.
> >
> > The format is slightly broken though in the case where the first option
> > is not being printed, like for example a group or a hidden option. In
> > that case, `show_gitcomp()` will of course skip that first entry. But
> > when printing the next option it checks for `opts == original_opts` to
> > verify whether we're printing the first option. The check will evaluate
> > to false though as we have skipped it, and thus we'll print a leading
> > space even though we have printed nothing else yet.
> >
> > Fix that bug by tracking whether we have already printed anything via a
> > local variable.
>
> Very clearly articulated. I would have chosen 'shown' as the
> variable name to so do, but 'first' may also be OK.
That's a fair point. We explicitly _don't_ care whether it's the first
entry or not, as that would match the old logic that caused this bug in
the first place. So `shown` is a better name indeed.
Patrick
next prev parent reply other threads:[~2026-10-02 7:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 10:13 [PATCH 0/3] builtin/refs: introduce subcommand groups Patrick Steinhardt
2026-10-01 10:13 ` [PATCH 1/3] parse-options: fix completion format when first option is skipped Patrick Steinhardt
2026-10-01 17:38 ` Junio C Hamano
2026-10-02 7:19 ` Patrick Steinhardt [this message]
2026-10-01 10:13 ` [PATCH 2/3] parse-options: allow grouping subcommands Patrick Steinhardt
2026-10-01 17:46 ` Junio C Hamano
2026-10-02 7:19 ` Patrick Steinhardt
2026-10-01 10:13 ` [PATCH 3/3] builtin/refs: introduce subcommand groups Patrick Steinhardt
2026-10-01 17:46 ` Junio C Hamano
2026-10-02 8:09 ` [PATCH v2 0/4] " Patrick Steinhardt
2026-10-02 8:09 ` [PATCH v2 1/4] parse-options: fix completion format when first option is skipped Patrick Steinhardt
2026-10-02 8:09 ` [PATCH v2 2/4] parse-options: extract functions to print single option Patrick Steinhardt
2026-10-02 8:09 ` [PATCH v2 3/4] parse-options: allow grouping subcommands Patrick Steinhardt
2026-10-02 8:09 ` [PATCH v2 4/4] builtin/refs: introduce subcommand groups Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ar9bDza3ImB71AIN@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox