Skip to content

Commit 91a640f

Browse files
committed
ls-remote: a lone "-h" is asking for help
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 <[email protected]>
1 parent 87b5054 commit 91a640f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

builtin/ls-remote.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
4141
struct transport *transport;
4242
const struct ref *ref;
4343

44+
if (argc == 2 && !strcmp("-h", argv[1]))
45+
usage(ls_remote_usage);
46+
4447
for (i = 1; i < argc; i++) {
4548
const char *arg = argv[i];
4649

0 commit comments

Comments
 (0)