Skip to content

Commit

Permalink
ls-remote: a lone "-h" is asking for help
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Sep 16, 2011
1 parent 87b5054 commit 91a640f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/ls-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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];

Expand Down

0 comments on commit 91a640f

Please sign in to comment.