Git development
 help / color / mirror / Atom feed
* [PATCH] ls-remote: a lone "-h" is asking for help
@ 2011-09-16 18:14 Junio C Hamano
  2011-09-16 19:09 ` Sverre Rabbelier
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2011-09-16 18:14 UTC (permalink / raw)
  To: git

What should happen if you run this command?

	$ git ls-remote -h

It does not give a short-help for the command. Instead because "-h" is a
synonym for "--heads", it runs "git ls-remote --heads", and because there
is no remote specified on the command line, we run it against the default
"origin" remote, hence end up doing the same as

	$ git ls-remote --heads origin

Fix this counter-intuitive behaviour by special casing a lone "-h" that
does not have anything else on the command line and calling usage().

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/ls-remote.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 1022309..41c88a9 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -43,6 +43,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	struct transport *transport;
 	const struct ref *ref;
 
+	if (argc == 2 && !strcmp("-h", argv[1]))
+		usage(ls_remote_usage);
+
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
 

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

end of thread, other threads:[~2011-09-16 20:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-16 18:14 [PATCH] ls-remote: a lone "-h" is asking for help Junio C Hamano
2011-09-16 19:09 ` Sverre Rabbelier
2011-09-16 19:35   ` Junio C Hamano
2011-09-16 19:44     ` Sverre Rabbelier
2011-09-16 20:31       ` Junio C Hamano
2011-09-16 20:34         ` Sverre Rabbelier
2011-09-16 20:53           ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox