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
Marcus Griep <marcus@griep.us>
Date
Aug 15, 2008, 21:17 UTC
Message-ID
<48A5F265.5080905@griep.us>
In-Reply-To
<B03ECD53-5920-4750-816F-890980C4CBD6@ai.rug.nl>
Pieter de Bie wrote:
> How about something simple like this?
Seems to do the job.
> diff --git a/builtin-help.c b/builtin-help.c

Are you working on next? Even though I know next is the new master. (master is soooo nearly last week. :-P)

I had a slightly different take. Your completion creates a 'k' for gitk, which was suggested earlier in the thread suggested is a bit harder to grok. This promotes 'git?' commands to use 'git?' rather than '?' without affecting things otherwise. ---

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c0bf7aa..0bb0d79 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -885,7 +885,9 @@ _git_help ()
                return
                ;;
        esac
-       __gitcomp "$(__git_all_commands)"
+       __gitcomp "$(ls $(./git help man-path)/man?/* |
+               sed -n -e 's/^.*\/git-\?\(.\{2,\}\)\.[0-9]$/\1/p' \
+                       -e 's/^.*\/git\(.\)\.[0-9]$/git\1/p')"
 }

 _git_init ()
diff --git a/help.c b/help.c
index 3cb1962..d0416e1 100644
--- a/help.c
+++ b/help.c
@@ -717,6 +717,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]);
---

What do you think, Junio?  If it works, I'll make this a
normal patch submission.
-- 
Marcus Griep
GPG Key ID: 0x5E968152
——
http://www.boohaunt.net
את.ψο´
Previous: Pieter de Bie
Message 12 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.