X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fls-remote.c;h=41c88a98a2de1ce817351243f9aa9e2811604097;hb=f52237576ab9ab054e8330ce5dc47f2020cbce74;hp=87d44bc62512cb014a7410fc2ad4e9559fffb608;hpb=91a640ffb6d9dd10c293a575a692d9771b6e13c7;p=git.git diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index 87d44bc62..41c88a98a 100644 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@ -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,7 +33,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) 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; @@ -72,6 +74,15 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) 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; @@ -97,6 +108,12 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) } 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); @@ -113,6 +130,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) 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; }