summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-23 17:27:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-05-23 17:27:08 (GMT)
commit3c0ae619e68398fe83d647b8460b399767ec103f (patch)
tree4a1e47bedda3d6bdc28b45aeeda057cb0c911bb3 /builtin
parent6bb696c304d2bf27b267202af193d99cc7995370 (diff)
parenta87247731e46255567ec58df940adb697e5b95a8 (diff)
downloadgit-3c0ae619e68398fe83d647b8460b399767ec103f.zip
git-3c0ae619e68398fe83d647b8460b399767ec103f.tar.gz
git-3c0ae619e68398fe83d647b8460b399767ec103f.tar.bz2
Merge branch 'ms/ls-remote-exit-with-status'
* ms/ls-remote-exit-with-status: ls-remote: the --exit-code option reports "no matching refs"
Diffstat (limited to 'builtin')
-rw-r--r--builtin/ls-remote.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 1a1ff87..1022309 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 <exec> | --upload-pack <exec>]\n"
-" [-q|--quiet] [<repository> [<refs>...]]";
+" [-q|--quiet] [--exit-code] [<repository> [<refs>...]]";
/*
* 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;
}