completion: complete 'git history --empty' values

The "--empty" option accepts "drop", "keep", or "abort" for the "drop"
and "fixup" subcommands. Complete these values for the documented

  --empty=<value>

form.

While parse-options also accepts the split

  --empty <value>

form, it is not documented. Omit it from completion as a trade-off for
code simplicity.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
main
Vincent Mailhol 2026-08-13 21:05:03 +02:00 committed by Junio C Hamano
parent 27be716454
commit 8231551929
2 changed files with 14 additions and 1 deletions

View File

@ -2169,6 +2169,15 @@ _git_history ()

if ! __git_has_doubledash; then
case "$cur" in
--empty=*)
case "$subcommand" in
drop|fixup)
__gitcomp "drop keep abort" "" \
"${cur##--empty=}"
;;
esac
return
;;
--*)
__gitcomp_builtin "history_$subcommand"
return

View File

@ -3127,7 +3127,11 @@ 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 fixup --empty=drop" "drop " &&
test_completion "git history drop --empty=ab" "abort " &&
test_completion "git history reword --empty=ke" ""
'

test_expect_success 'git history revisions' '