Re: [PATCH v2 2/4] completion: complete 'git history --empty' values
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Aug 10, 2026, 12:50 UTC
- Message-ID
- <CALnO6CAssyDe7uOK+G8eZPzu1S6iyn8EiSQGqUHtWgdPcD65xw@mail.gmail.com>
- In-Reply-To
- <20260806-history_autocompletion-v2-2-7e60f52a1c20@kernel.org>
One other thing, sorry
On Thu, Aug 6, 2026 at 4:36 PM Vincent Mailhol <mailhol@kernel.org> wrote:
Show 38 quoted lines
> > The "--empty" option accepts "drop", "keep", or "abort" for the "drop" > and "fixup" subcommands. Complete these values. > > Although the synopsis only documents the: > > --empty=<value> > > form, parse-options also accepts the value as a separate argument: > > --empty <value> > > Support both forms to follow the parser. > > Signed-off-by: Vincent Mailhol <mailhol@kernel.org> > --- > Changes in v2: > > - New patch. > --- > contrib/completion/git-completion.bash | 13 +++++++++++-- > t/t9902-completion.sh | 5 ++++- > 2 files changed, 15 insertions(+), 3 deletions(-) > > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash > index 7372e2919b..fe5223b8ec 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -2171,8 +2171,17 @@ _git_history () > fi > > if ! __git_has_doubledash; then > - case "$cur" in > - --*) > + case "$prev,$cur" in > + --empty,*|*,--empty=*) > + case "$subcommand" in > + drop|fixup)
This feels a bit "inside out" to me, especially when reading the other completions. I think the usual pattern is to check the subcommand first and dispatch if necessary. Thoughts?
Show 10 quoted lines
> + __gitcomp "drop keep abort" "" \
> + "${cur##--empty=}"
> + return
> + ;;
> + esac
> + ;;
> + *,--*)
> __gitcomp_builtin "history_$subcommand"
> return
> ;;[snip]
-- D. Ben Knoble