git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Vincent Mailhol <mailhol@kernel.org>
Date
Aug 13, 2026, 19:05 UTC
Message-ID
<20260813-history_autocompletion-v3-0-69eed1cea93a@kernel.org>
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

Previous: Patrick SteinhardtNext: Vincent Mailhol
Message 7 of 18 in “completion: add 'git history' subcommands”
  1. completion: add 'git history' subcommandsVincent Mailhol, Aug 4, 2026
  2. Patrick SteinhardtAug 5, 2026
  3. D. Ben KnobleAug 5, 2026
  4. Junio C HamanoAug 5, 2026
  5. Vincent MailholAug 5, 2026
  6. Patrick SteinhardtAug 6, 2026
  7. 0/4 completion: add support for 'git history'Vincent Mailhol, Aug 13, 2026
  8. 1/4 completion: add 'git history' subcommandsVincent Mailhol, Aug 13, 2026
  9. Patrick SteinhardtAug 19, 2026
  10. 2/4 completion: complete 'git history --empty' valuesVincent Mailhol, Aug 13, 2026
  11. Patrick SteinhardtAug 19, 2026
  12. 3/4 completion: complete 'git history --update-refs' valuesVincent Mailhol, Aug 13, 2026
  13. 4/4 completion: complete 'git history split' pathspecsVincent Mailhol, Aug 13, 2026
  14. Kristoffer HaugsbakkAug 13, 2026
  15. Vincent MailholAug 14, 2026
  16. Kristoffer HaugsbakkAug 14, 2026
  17. Patrick SteinhardtAug 19, 2026
  18. Junio C HamanoAug 19, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.