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>,
Ben Knoble <ben.knoble@gmail.com>,
Vincent Mailhol <mailhol@kernel.org>
Subject: [PATCH v3 0/4] completion: add support for 'git history'
Date: Thu, 13 Aug 2026 21:05:01 +0200 [thread overview]
Message-ID: <20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org> (raw)
In-Reply-To: <20260804-history_autocompletion-v1-1-6f7459ffb677@kernel.org>
This series adds Bash completion for the subcommands of "git history"
and their options.
Patch #1 adds the basic subcommand and options completion. Patch #2 and
options. Finally, Patch #4 adds completion for pathspecs accepted by
"split".
For each of the completions, add a set of relevant test cases.
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
Changes in v3:
- Ignore the split "<option> <value>" syntax for options that take
arguments. This simplifies revision detection and avoids hard-coding
option names.
- Test that options are not completed before a subcommand.
Link to v2: https://lore.kernel.org/r/20260806-history_autocompletion-v2-0-7e60f52a1c20@kernel.org
Changes in v2:
- Complete exactly one required revision and leave subsequent
arguments to subcommand-specific completion.
- Do not complete options after "--".
- Complete values for "--empty" and "--update-refs".
- Complete pathspecs for "git history split".
- Expand the test coverage for options, revisions, and pathspecs.
Link to v1: https://lore.kernel.org/r/20260804-history_autocompletion-v1-1-6f7459ffb677@kernel.org
---
Vincent Mailhol (4):
completion: add 'git history' subcommands
completion: complete 'git history --empty' values
completion: complete 'git history --update-refs' values
completion: complete 'git history split' pathspecs
contrib/completion/git-completion.bash | 65 ++++++++++++++++++++++++++++++++++
t/t9902-completion.sh | 50 ++++++++++++++++++++++++++
2 files changed, 115 insertions(+)
Range-diff versus v2:
1: 529ecbe28c ! 1: 5764875d09 completion: add 'git history' subcommands
@@ Commit message
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
+ Changes in v3:
+
+ - Ignore the split "<option> <value>" syntax for options that take
+ arguments. This simplifies revision detection and avoids hard-coding
+ option names.
+ - Test that options are not completed before a subcommand.
+
Changes in v2:
- Test options before and after revisions.
- Do not complete options after "--".
- - Stop revision completion after the first required
+ - Stop revision completion after the first required revision.
## contrib/completion/git-completion.bash ##
@@ contrib/completion/git-completion.bash: _git_help ()
@@ contrib/completion/git-completion.bash: _git_help ()
+
+ for ((i = __git_cmd_idx + 2; i < cword; i++)); do
+ case "${words[i]}" in
-+ --empty|--update-refs)
-+ ((i++))
-+ ;;
+ -*)
+ ;;
+ *)
@@ t/t9902-completion.sh: test_expect_success 'git clone --config= - value' '
'
+test_expect_success 'git history subcommands' '
-+ test_completion "git history " <<-\EOF
++ test_completion "git history " <<-\EOF &&
+ drop Z
+ fixup Z
+ reword Z
+ split Z
+ EOF
++ test_completion "git history --" ""
+'
+
+test_expect_success 'git history subcommand options' '
@@ t/t9902-completion.sh: test_expect_success 'git clone --config= - value' '
+
+test_expect_success 'git history revisions' '
+ test_completion "git history split ma" "main " &&
-+ test_completion "git history split --update-refs head ma" "main " &&
-+ test_completion "git history fixup --empty drop ma" "main " &&
++ test_completion "git history split --update-refs=head ma" "main " &&
++ test_completion "git history fixup --empty=drop ma" "main " &&
+ test_completion "git history reword main m" ""
+'
+
2: 691965330f < -: ---------- completion: complete 'git history --empty' values
3: 02303a7762 < -: ---------- completion: complete 'git history --update-refs' values
-: ---------- > 2: 224fb8dc32 completion: complete 'git history --empty' values
-: ---------- > 3: 60a54d5a8b completion: complete 'git history --update-refs' values
4: 39823df359 ! 4: c895589110 completion: complete 'git history split' pathspecs
@@ Commit message
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
+ Changes in v3:
+
+ - No changes.
+
Changes in v2:
- New patch.
---
base-commit: 4f2b99511996c64e58c74e2b8bd3d7ec33452a47
change-id: 20260804-history_autocompletion-84620c2f8500
next prev parent reply other threads:[~2026-08-13 19:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 19:56 [PATCH] completion: add 'git history' subcommands Vincent Mailhol
2026-08-05 6:19 ` 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
2026-08-13 19:05 ` Vincent Mailhol [this message]
2026-08-13 19:05 ` [PATCH v3 1/4] " Vincent Mailhol
2026-08-13 19:05 ` [PATCH v3 2/4] completion: complete 'git history --empty' values Vincent Mailhol
2026-08-13 19:05 ` [PATCH v3 3/4] completion: complete 'git history --update-refs' values Vincent Mailhol
2026-08-13 19:05 ` [PATCH v3 4/4] completion: complete 'git history split' pathspecs Vincent Mailhol
2026-08-13 20:30 ` [PATCH v3 0/4] completion: add support for 'git history' Kristoffer Haugsbakk
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=20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org \
--to=mailhol@kernel.org \
--cc=ben.knoble@gmail.com \
--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