From: Patrick Steinhardt Date: Fri, 02 Oct 2026 07:19:43 GMT Subject: Re: [PATCH 1/3] parse-options: fix completion format when first option is skipped Message-ID: In-Reply-To: On Thu, Oct 01, 2026 at 10:38:08AM -0700, Junio C Hamano wrote: > Patrick Steinhardt 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