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] completion: add 'git history' subcommands
Date: Tue, 04 Aug 2026 21:56:32 +0200 [thread overview]
Message-ID: <20260804-history_autocompletion-v1-1-6f7459ffb677@kernel.org> (raw)
Use the parse-options completion helpers for the "git history"
subcommands and their options. Complete positional arguments as
revisions, and add coverage for each kind of completion.
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
contrib/completion/git-completion.bash | 24 ++++++++++++++++++++++++
t/t9902-completion.sh | 17 +++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e875787710..f10813c8d7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2137,6 +2137,30 @@ _git_help ()
fi
}
+_git_history ()
+{
+ local subcommands subcommand
+
+ __git_resolve_builtins "history"
+
+ subcommands="$___git_resolved_builtins"
+ subcommand="$(__git_find_subcommand "$subcommands")"
+
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ return
+ fi
+
+ case "$cur" in
+ --*)
+ __gitcomp_builtin "history_$subcommand"
+ ;;
+ *)
+ __git_complete_refs
+ ;;
+ esac
+}
+
_git_init ()
{
case "$cur" in
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 9ae3c48ebd..08ecf682ed 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -3107,6 +3107,23 @@ test_expect_success 'git clone --config= - value' '
EOF
'
+test_expect_success 'git history subcommands' '
+ test_completion "git history " <<-\EOF
+ drop Z
+ fixup Z
+ reword Z
+ split Z
+ EOF
+'
+
+test_expect_success 'git history subcommand options' '
+ test_completion "git history fixup --upd" "--update-refs="
+'
+
+test_expect_success 'git history revisions' '
+ test_completion "git history split ma" "main "
+'
+
test_expect_success 'git reflog show' '
test_when_finished "git checkout - && git branch -d shown" &&
git checkout -b shown &&
---
base-commit: 5b2471720c93ee30e5764a19f3d3b3ae9ec9712a
change-id: 20260804-history_autocompletion-84620c2f8500
next reply other threads:[~2026-08-04 19:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 19:56 Vincent Mailhol [this message]
2026-08-05 6:19 ` [PATCH] completion: add 'git history' subcommands Patrick Steinhardt
2026-08-05 11:56 ` D. Ben Knoble
2026-08-05 16:15 ` Junio C Hamano
2026-08-05 21:20 ` Vincent Mailhol
2026-08-06 5:18 ` Patrick Steinhardt
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=20260804-history_autocompletion-v1-1-6f7459ffb677@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