Thread (9 messages) flat view 9 messages, 2 authors, 9h ago
HOTtoday

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

From: Vincent Mailhol <mailhol@kernel.org>
Date: 2026-08-06 20:27:50
Subsystem: the rest · Maintainer: Linus Torvalds

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)
+				__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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help