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

Re: [PATCH] Add subcommand "help" to the list of most commonly used subcommands

From
TLTeemu Likonen <tlikonen@iki.fi>
Date
Jun 5, 2008, 21:15 UTC
Message-ID
<20080605211536.GA4328@mithlond.arda.local>
In-Reply-To
<408F1687-FC42-4E96-B641-088F200CE8D1@ai.rug.nl>
Pieter de Bie wrote (2008-06-05 20:38 +0200):
Show 7 quoted lines
> On 5 jun 2008, at 20:13, Junio C Hamano wrote:
> 
> >See 'man git' and 'git help' for more information.
> 
> I'd like to see something more like
> 
> See 'git help COMMAND' for more information on a specific command

Sounds good. Here comes my first _ever_ attempt on C "programming". It implements (i.e. tries to) what pretty much seems like an agreement on the list: a separate info line after the command list. If the patch sucks, well, at least I've had fun trying. And there's no need to ask me to defend my code; I'm not able to answer. :-)

---snip--- Print info about "git help COMMAND" on git's main usage pages

Git's main usage pages did not show "git help" as a way to get more information on a specific subcommand. This patch adds an info line after the list of git commands currently printed by "git", "git help", "git --help" and "git help --all".

Signed-off-by: Teemu Likonen <tlikonen@iki.fi>
---
 builtin.h |    1 +
 git.c     |    4 ++++
 help.c    |    2 ++
 3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/builtin.h b/builtin.h
index 8bda111..b460b2d 100644
--- a/builtin.h
+++ b/builtin.h
@@ -5,6 +5,7 @@
 
 extern const char git_version_string[];
 extern const char git_usage_string[];
+extern const char git_more_info_string[];
 
 extern void list_common_cmds_help(void);
 extern void help_unknown_cmd(const char *cmd);
diff --git a/git.c b/git.c
index 272bf03..15a0e71 100644
--- a/git.c
+++ b/git.c
@@ -6,6 +6,9 @@
 const char git_usage_string[] =
 	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
 
+const char git_more_info_string[] =
+	"See 'git help COMMAND' for more information on a specific command.";
+
 static int handle_options(const char*** argv, int* argc, int* envchanged)
 {
 	int handled = 0;
@@ -427,6 +430,7 @@ int main(int argc, const char **argv)
 		/* The user didn't specify a command; give them help */
 		printf("usage: %s\n\n", git_usage_string);
 		list_common_cmds_help();
+		printf("\n%s\n", git_more_info_string);
 		exit(1);
 	}
 	cmd = argv[0];
diff --git a/help.c b/help.c
index d89d437..8aff94c 100644
--- a/help.c
+++ b/help.c
@@ -649,12 +649,14 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 	if (show_all) {
 		printf("usage: %s\n\n", git_usage_string);
 		list_commands();
+		printf("%s\n", git_more_info_string);
 		return 0;
 	}
 
 	if (!argv[0]) {
 		printf("usage: %s\n\n", git_usage_string);
 		list_common_cmds_help();
+		printf("\n%s\n", git_more_info_string);
 		return 0;
 	}
 
-- 
1.5.6.rc1.16.gc6796
Previous: Pieter de BieNext: Junio C Hamano
Message 12 of 28 in “git wrapper: show similar command names for an unknown command”
  1. git wrapper: show similar command names for an unknown commandJohannes Schindelin, Jun 5, 2008
  2. Add subcommand "help" to the list of most commonly used subcommandsTeemu Likonen, Jun 5, 2008
  3. Johannes SchindelinJun 5, 2008
  4. Teemu LikonenJun 5, 2008
  5. 1/2 Add subcommand "help" to the list of most commonly used subcommandsTeemu Likonen, Jun 5, 2008
  6. 2/2 More informative short description for git-help.txtTeemu Likonen, Jun 5, 2008
  7. Johannes SchindelinJun 5, 2008
  8. Sverre RabbelierJun 5, 2008
  9. Teemu LikonenJun 5, 2008
  10. Junio C HamanoJun 5, 2008
  11. Pieter de BieJun 5, 2008
  12. Teemu LikonenJun 5, 2008
  13. Junio C HamanoJun 5, 2008
  14. David SymondsJun 6, 2008
  15. Wincent ColaiutaJun 5, 2008
  16. Sverre RabbelierJun 5, 2008
  17. Dirk SüsserottJun 5, 2008
  18. Johannes SchindelinJun 5, 2008
  19. Robin RosenbergJun 6, 2008
  20. Wincent ColaiutaJun 6, 2008
  21. Alex RiesenJun 7, 2008
  22. Johannes SchindelinJun 7, 2008
  23. Alex RiesenJun 7, 2008
  24. Junio C HamanoJun 7, 2008
  25. Johannes SchindelinJun 8, 2008
  26. Dirk SüsserottJun 8, 2008
  27. Junio C HamanoJun 8, 2008
  28. Johannes SchindelinJun 8, 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.