[PATCH v3 0/4] completion: add support for 'git history'
Vincent Mailhol <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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/[email protected] 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/[email protected] --- 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 <[email protected]> --- + 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 <[email protected]> --- + Changes in v3: + + - No changes. + Changes in v2: - New patch. --- base-commit: 4f2b99511996c64e58c74e2b8bd3d7ec33452a47 change-id: 20260804-history_autocompletion-84620c2f8500