Thread (14 messages) flat view 14 messages, 5 authors, 1d ago
WARM1d

Revision v3 of 2 in this series.

Revisions (2)
  1. v2 [diff vs current]
  2. v3 current

[PATCH v3 0/4] completion: add support for 'git history'

From: Vincent Mailhol <mailhol@kernel.org>
Date: 2026-08-13 19:05:25

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 (local)

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 (local)

---
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 [off-list ref]
         ---
    +    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 [off-list ref]
         ---
    +    Changes in v3:
    +
    +      - No changes.
    +
         Changes in v2:
     
           - New patch.

---
base-commit: 4f2b99511996c64e58c74e2b8bd3d7ec33452a47
change-id: 20260804-history_autocompletion-84620c2f8500
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help