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

Re: [PATCH] bash-completion: Add non-command git help files to bash-completion

From
PBPieter de Bie <pdebie@ai.rug.nl>
Date
Aug 15, 2008, 20:32 UTC
Message-ID
<B03ECD53-5920-4750-816F-890980C4CBD6@ai.rug.nl>
In-Reply-To
<7vvdy29kok.fsf@gitster.siamese.dyndns.org>
On 15 aug 2008, at 20:50, Junio C Hamano wrote:
Show 22 quoted lines
> 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  
> <TAB>"
> 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 <TAB>" 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')"
  }
Previous: Marcus GriepNext: Marcus Griep
Message 11 of 12 in “bash-completion: Add non-command git help files to bash-completion”
  1. bash-completion: Add non-command git help files to bash-completionMarcus Griep, Aug 15, 2008
  2. Jonathan NiederAug 15, 2008
  3. Marcus GriepAug 15, 2008
  4. bash-completion: Add non-command git help files to bash-completionMarcus Griep, Aug 15, 2008
  5. Shawn O. PearceAug 15, 2008
  6. Junio C HamanoAug 16, 2008
  7. Junio C HamanoAug 15, 2008
  8. Marcus GriepAug 15, 2008
  9. Junio C HamanoAug 15, 2008
  10. Marcus GriepAug 15, 2008
  11. Pieter de BieAug 15, 2008
  12. Marcus GriepAug 15, 2008

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.