From: Junio C Hamano Date: Wed, 5 Oct 2011 19:36:26 +0000 (-0700) Subject: Merge branch 'jc/ls-remote-short-help' X-Git-Tag: v1.7.8-rc0~124 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f52237576ab9ab054e8330ce5dc47f2020cbce74?ds=inline;hp=-c Merge branch 'jc/ls-remote-short-help' * jc/ls-remote-short-help: ls-remote: a lone "-h" is asking for help --- f52237576ab9ab054e8330ce5dc47f2020cbce74 diff --combined builtin/ls-remote.c index 10223092a9,87d44bc625..41c88a98a2 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@@ -5,7 -5,7 +5,7 @@@ static const char ls_remote_usage[] = "git ls-remote [--heads] [--tags] [-u | --upload-pack ]\n" -" [-q|--quiet] [ [...]]"; +" [-q|--quiet] [--exit-code] [ [...]]"; /* * Is there one among the list of patterns that match the tail part @@@ -33,9 -33,7 +33,9 @@@ int cmd_ls_remote(int argc, const char int i; const char *dest = NULL; unsigned flags = 0; + int get_url = 0; int quiet = 0; + int status = 0; const char *uploadpack = NULL; const char **pattern = NULL; @@@ -43,6 -41,9 +43,9 @@@ 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]; @@@ -71,15 -72,6 +74,15 @@@ quiet = 1; continue; } + if (!strcmp("--get-url", arg)) { + get_url = 1; + continue; + } + if (!strcmp("--exit-code", arg)) { + /* return this code if no refs are reported */ + status = 2; + continue; + } usage(ls_remote_usage); } dest = arg; @@@ -105,12 -97,6 +108,12 @@@ } if (!remote->url_nr) die("remote %s has no configured URL", dest); + + if (get_url) { + printf("%s\n", *remote->url); + return 0; + } + transport = transport_get(remote, NULL); if (uploadpack != NULL) transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack); @@@ -127,7 -113,6 +130,7 @@@ if (!tail_match(pattern, ref->name)) continue; printf("%s %s\n", sha1_to_hex(ref->old_sha1), ref->name); + status = 0; /* we found something */ } - return 0; + return status; }