git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/4] completion: complete 'git history --empty' values

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Aug 10, 2026, 12:48 UTC
Message-ID
<CALnO6CCCG0xcZtAKQdNsKxNJ2Nyq5HztLaz_7QXjfQsN-q-xgA@mail.gmail.com>
In-Reply-To
<20260806-history_autocompletion-v2-2-7e60f52a1c20@kernel.org>
On Thu, Aug 6, 2026 at 4:36 PM Vincent Mailhol <mailhol@kernel.org> wrote:
Show 13 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.

Comments on 1/4 apply here, too. I don't mind supporting both, but I wonder if we should be consistent with gitcli(1) and just go with the stuck form.

I can only find one hit for the pattern "--[[:alnum:]-]+[^=],?\*" (use "git grep -E") in the completion code, and it's "--no-*)", so I'm not sure if other commands support completing the unstuck form? For example, "git commit --cleanup <tab>" doesn't complete the mode argument, but "git commit --cleanup=<tab>" does.

Show 56 quoted lines
>
> 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)
> +                               __gitcomp "drop keep abort" "" \
> +                                       "${cur##--empty=}"
> +                               return
> +                               ;;
> +                       esac
> +                       ;;
> +               *,--*)
>                         __gitcomp_builtin "history_$subcommand"
>                         return
>                         ;;
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index 5ccb38c751..52a036a1ad 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -3126,7 +3126,10 @@ test_expect_success 'git history subcommand options' '
>         test_completion "git history fixup --ree" "--reedit-message " &&
>         test_completion "git history split --upd" "--update-refs=" &&
>         test_completion "git history split main --dry" "--dry-run " &&
> -       test_completion "git history reword main -- --d" ""
> +       test_completion "git history reword main -- --d" "" &&
> +       test_completion "git history fixup --empty=ke" "keep " &&
> +       test_completion "git history drop --empty ab" "abort " &&
> +       test_completion "git history reword --empty=ke" ""
>  '
>
>  test_expect_success 'git history revisions' '
>
> --
> 2.54.0
>
>
-- 
D. Ben Knoble
Previous: Vincent MailholNext: D. Ben Knoble
Message 9 of 17 in “completion: add support for 'git history'”
  1. 0/4 completion: add support for 'git history'Vincent Mailhol, Aug 6, 2026
  2. 1/4 completion: add 'git history' subcommandsVincent Mailhol, Aug 6, 2026
  3. Patrick SteinhardtAug 7, 2026
  4. Vincent MailholAug 7, 2026
  5. Patrick SteinhardtAug 7, 2026
  6. Vincent MailholAug 7, 2026
  7. D. Ben KnobleAug 10, 2026
  8. 2/4 completion: complete 'git history --empty' valuesVincent Mailhol, Aug 6, 2026
  9. D. Ben KnobleAug 10, 2026
  10. D. Ben KnobleAug 10, 2026
  11. Vincent MailholAug 13, 2026
  12. Ben KnobleAug 13, 2026
  13. Vincent MailholAug 13, 2026
  14. 3/4 completion: complete 'git history --update-refs' valuesVincent Mailhol, Aug 6, 2026
  15. D. Ben KnobleAug 10, 2026
  16. 4/4 completion: complete 'git history split' pathspecsVincent Mailhol, Aug 6, 2026
  17. D. Ben KnobleAug 10, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.