Merge branch 'ab/complete-show-all-commands'

The command line completion script (in contrib/) learned to
complete all Git subcommands, including the ones that are normally
hidden, when GIT_COMPLETION_SHOW_ALL_COMMANDS is used.

* ab/complete-show-all-commands:
  completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDS
  completion tests: re-source git-completion.bash in a subshell
This commit is contained in:
Junio C Hamano
2022-02-17 16:25:05 -08:00
2 changed files with 72 additions and 22 deletions

View File

@ -49,6 +49,11 @@
# and git-switch completion (e.g., completing "foo" when "origin/foo"
# exists).
#
# GIT_COMPLETION_SHOW_ALL_COMMANDS
#
# When set to "1" suggest all commands, including plumbing commands
# which are hidden by default (e.g. "cat-file" on "git ca<TAB>").
#
# GIT_COMPLETION_SHOW_ALL
#
# When set to "1" suggest all options, including options which are
@ -3483,7 +3488,13 @@ __git_main ()
then
__gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
else
__gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
local list_cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config
if test "${GIT_COMPLETION_SHOW_ALL_COMMANDS-}" = "1"
then
list_cmds=builtins,$list_cmds
fi
__gitcomp "$(__git --list-cmds=$list_cmds)"
fi
;;
esac