From 8231551929aa7fa2043c18753c736829c88df8d7 Mon Sep 17 00:00:00 2001 From: Vincent Mailhol Date: Thu, 13 Aug 2026 21:05:03 +0200 Subject: [PATCH] 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= form. While parse-options also accepts the split --empty form, it is not documented. Omit it from completion as a trade-off for code simplicity. Signed-off-by: Vincent Mailhol Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 9 +++++++++ t/t9902-completion.sh | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 1727768487..7f3cabd595 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -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 diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index d0d8f2ba4a..851be383e1 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -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' '