X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fls-remote.c;h=10223092a9ebfed4092db680529a42ca8886a9f2;hb=18322badc2b3b7f49f79da5273e003e9c0c4f549;hp=1a1ff87e8f9ed7db84f106960f36888835f7057b;hpb=5b42477b59886a85d4b49a60313f9b9d4a0d576f;p=git.git diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index 1a1ff87e8..10223092a 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 @@ -35,6 +35,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) unsigned flags = 0; int get_url = 0; int quiet = 0; + int status = 0; const char *uploadpack = NULL; const char **pattern = NULL; @@ -74,6 +75,11 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) 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; @@ -121,6 +127,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; }