Git development
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol@kernel.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	 Philippe Blain <levraiphilippeblain@gmail.com>,
	 Patrick Steinhardt <ps@pks.im>,
	Vincent Mailhol <mailhol@kernel.org>
Subject: [PATCH v2 2/4] completion: complete 'git history --empty' values
Date: Thu, 06 Aug 2026 22:27:37 +0200	[thread overview]
Message-ID: <20260806-history_autocompletion-v2-2-7e60f52a1c20@kernel.org> (raw)
In-Reply-To: <20260806-history_autocompletion-v2-0-7e60f52a1c20@kernel.org>

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


  parent reply	other threads:[~2026-08-06 20:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 20:27 [PATCH v2 0/4] completion: add support for 'git history' Vincent Mailhol
2026-08-06 20:27 ` [PATCH v2 1/4] completion: add 'git history' subcommands Vincent Mailhol
2026-08-07  6:30   ` Patrick Steinhardt
2026-08-07  6:44     ` Vincent Mailhol
2026-08-07  7:08       ` Patrick Steinhardt
2026-08-07  8:09         ` Vincent Mailhol
2026-08-06 20:27 ` Vincent Mailhol [this message]
2026-08-06 20:27 ` [PATCH v2 3/4] completion: complete 'git history --update-refs' values Vincent Mailhol
2026-08-06 20:27 ` [PATCH v2 4/4] completion: complete 'git history split' pathspecs Vincent Mailhol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260806-history_autocompletion-v2-2-7e60f52a1c20@kernel.org \
    --to=mailhol@kernel.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=levraiphilippeblain@gmail.com \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox