git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Support "git cmd --help" syntax
@ 2006-04-15 18:13 Linus Torvalds
  2006-04-15 20:54 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2006-04-15 18:13 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List


The "--help" argument is special, in that it is (along with "--version") 
in that is taken by the "git" program itself rather than the sub-command, 
and thus we've had the syntax "git --help cmd".

However, as anybody who has ever used CVS or some similar devil-spawn 
program, it's confusing as h*ll when options before the sub-command act 
differently from options after the sub-command, so this quick hack just 
makes it acceptable to do "git cmd --help" instead, and get the exact same 
result.

It may be hacky, but it's simple and does the trick.

Of course, this does not help if you use one of the non-builtin commands 
without using the "git" helper. Ie you won't be getting a man-page just 
because you do "git-rev-list --help". Don't expect us to be quite _that_ 
helpful.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/git.c b/git.c
index 78ed403..13c6d51 100644
--- a/git.c
+++ b/git.c
@@ -411,6 +411,12 @@ static void handle_internal_command(int 
 	};
 	int i;
 
+	/* Turn "git cmd --help" into "git help cmd" */
+	if (argc > 1 && !strcmp(argv[1], "--help")) {
+		argv[1] = argv[0];
+		argv[0] = cmd = "help";
+	}
+
 	for (i = 0; i < ARRAY_SIZE(commands); i++) {
 		struct cmd_struct *p = commands+i;
 		if (strcmp(p->cmd, cmd))

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-19 21:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-15 18:13 Support "git cmd --help" syntax Linus Torvalds
2006-04-15 20:54 ` Junio C Hamano
2006-04-15 21:07   ` Linus Torvalds
2006-04-16  1:24     ` Junio C Hamano
2006-04-19 21:40     ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).