completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 4 repliesIn review
- v11 patch 1 replySuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | completion tests: re-source git-completion.bash in a subshellt/ | +29 | 0 replies | |
| 2/2 | completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDScontrib/ t/ | +43 | 4 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS
This series adds an opt-in configuration to make "git <TAB>" complete the likes of "cat-file" (plumbing), in addition to the existing completion for the likes of "status" (porcelain).
This v2 addresses feedback from Junio on the v1, I also added a preceding patch to change the re-sourcing of git-completion.bash in some existing tests to use a subshell, which is a pattern I'd buggily copied in the v1.
Ævar Arnfjörð Bjarmason (2):
completion tests: re-source git-completion.bash in a subshell
completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS
contrib/completion/git-completion.bash | 13 ++++- t/t9902-completion.sh | 81 +++++++++++++++++++------- 2 files changed, 72 insertions(+), 22 deletions(-)
Range-diff against v1:
-: ----------- > 1: cf09546e079 completion tests: re-source git-completion.bash in a subshell
1: 5f18305ca08 ! 2: 2e2e3569e02 completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS
@@ Commit message
completion with git <TAB>, respectively.
It was already possible to do this by tweaking
- GIT_COMPLETION_SHOW_ALL_COMMANDS from the outside, that testing
+ GIT_TESTING_PORCELAIN_COMMAND_LIST= from the outside, that testing
variable was added in 84a97131065 (completion: let git provide the
completable command list, 2018-05-20). Doing this before loading
git-completion.bash worked:
@@ Commit message
and we make no guarantees that those internal won't change. So let's
expose this as a dedicated configuration knob.
+ It would be better to teach --list-cmds=* a new category which would
+ include all of these groups, but that's a larger change that we can
+ leave for some other time.
+
1. https://lore.kernel.org/git/CAGP6POJ9gwp+t-eP3TPkivBLLbNb2+qj=61Mehcj=1BgrVOSLA@mail.gmail.com/
Reported-by: Hongyi Zhao <[email protected]>
@@ contrib/completion/git-completion.bash: __git_main ()
## t/t9902-completion.sh ##
@@ t/t9902-completion.sh: test_expect_success 'option aliases are shown with GIT_COMPLETION_SHOW_ALL' '
- EOF
+ )
'
+test_expect_success 'plumbing commands are excluded without GIT_COMPLETION_SHOW_ALL_COMMANDS' '
-+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
-+ sane_unset GIT_TESTING_PORCELAIN_COMMAND_LIST &&
++ (
++ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
++ sane_unset GIT_TESTING_PORCELAIN_COMMAND_LIST &&
+
-+ # Just mainporcelain, not plumbing commands
-+ run_completion "git c" &&
-+ grep checkout out &&
-+ ! grep cat-file out
++ # Just mainporcelain, not plumbing commands
++ run_completion "git c" &&
++ grep checkout out &&
++ ! grep cat-file out
++ )
+'
+
+test_expect_success 'all commands are shown with GIT_COMPLETION_SHOW_ALL_COMMANDS (also main non-builtin)' '
-+ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
-+ GIT_COMPLETION_SHOW_ALL_COMMANDS=1 &&
-+ export GIT_COMPLETION_SHOW_ALL_COMMANDS &&
-+ sane_unset GIT_TESTING_PORCELAIN_COMMAND_LIST &&
++ (
++ . "$GIT_BUILD_DIR/contrib/completion/git-completion.bash" &&
++ GIT_COMPLETION_SHOW_ALL_COMMANDS=1 &&
++ export GIT_COMPLETION_SHOW_ALL_COMMANDS &&
++ sane_unset GIT_TESTING_PORCELAIN_COMMAND_LIST &&
+
-+ # Both mainporcelain and plumbing commands
-+ run_completion "git c" &&
-+ grep checkout out &&
-+ grep cat-file out &&
++ # Both mainporcelain and plumbing commands
++ run_completion "git c" &&
++ grep checkout out &&
++ grep cat-file out &&
+
-+ # Check "gitk", a "main" command, but not a built-in + more plumbing
-+ run_completion "git g" &&
-+ grep gitk out &&
-+ grep get-tar-commit-id out
++ # Check "gitk", a "main" command, but not a built-in + more plumbing
++ run_completion "git g" &&
++ grep gitk out &&
++ grep get-tar-commit-id out
++ )
+'
+
test_expect_success '__git_complete' 'Signature · 1 line
2.35.0.913.g12b4baa2536