From: Pieter de Bie Date: Fri, 15 Aug 2008 20:32:16 GMT Subject: Re: [PATCH] bash-completion: Add non-command git help files to bash-completion Message-ID: In-Reply-To: <7vvdy29kok.fsf@gitster.siamese.dyndns.org> On 15 aug 2008, at 20:50, Junio C Hamano wrote: > That is exactly what I mean. I do not think bloating shell > completion to > enumerate what help topics there are when the user hits "git help > " > is a good idea to begin with. It is a maintenance nightmere for one > thing, and it does not help non-bash users. > > $ git help > $ git help --all > > are existing ways for you to get list of "command topics" that you > can ask > the help system about, but I do not see a way to ask "git-help, please > tell me what topics that are not git-commands can I ask you about?", > hence > my suggestion to add "git help topics". > > And if you based "git help " completion on the output from such > help > subcommand, you would not have to maintain the list of topics > yourself in > the completion script, and I would not mind such a patch too much. How about something simple like this? diff --git a/builtin-help.c b/builtin-help.c index 391f749..a49b5c2 100644 --- a/builtin-help.c +++ b/builtin-help.c @@ -446,6 +446,11 @@ int cmd_help(int argc, const char **argv, const char *prefix) return 0; } + if (!strcmp("man-path", argv[0])) { + printf("%s\n", GIT_MAN_PATH); + return 0; + } + switch (help_format) { case HELP_FORMAT_MAN: show_man_page(argv[0]); diff --git a/contrib/completion/git-completion.bash b/contrib/ completion/git-completion.bash index 3396e35..f781661 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -885,7 +885,8 @@ _git_help () return ;; esac - __gitcomp "$(__git_all_commands)" + __gitcomp "$(ls $(./git help man-path)/man?/* | + sed -n 's/^.*\/git-\{0,1\}\(.*\)\.[0-9]$/\1/p')" }