summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-11-01 19:13:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-11-01 20:09:45 (GMT)
commit9dc01bf0631b51dfe497d57942a9085e0808e205 (patch)
tree219613f78b4449d6924e69e9bd3e3848ee53f89d /builtin/rev-parse.c
parentff32d3420a550d3811e745af7f2ccc77fb026b7b (diff)
downloadgit-9dc01bf0631b51dfe497d57942a9085e0808e205.zip
git-9dc01bf0631b51dfe497d57942a9085e0808e205.tar.gz
git-9dc01bf0631b51dfe497d57942a9085e0808e205.tar.bz2
rev-parse: introduce --exclude=<glob> to tame wildcards
Teach "rev-parse" the same "I'm going to glob, but omit the ones that match these patterns" feature as "rev-list". Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r--builtin/rev-parse.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index de894c7..f52f804 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -9,6 +9,8 @@
#include "quote.h"
#include "builtin.h"
#include "parse-options.h"
+#include "diff.h"
+#include "revision.h"
#define DO_REVS 1
#define DO_NOREV 2
@@ -30,6 +32,8 @@ static int abbrev_ref;
static int abbrev_ref_strict;
static int output_sq;
+static struct string_list *ref_excludes;
+
/*
* Some arguments are relevant "revision" arguments,
* others are about output format or other details.
@@ -185,6 +189,8 @@ static int show_default(void)
static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
+ if (ref_excluded(ref_excludes, refname))
+ return 0;
show_rev(NORMAL, sha1, refname);
return 0;
}
@@ -633,32 +639,43 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
if (!prefixcmp(arg, "--branches=")) {
for_each_glob_ref_in(show_reference, arg + 11,
"refs/heads/", NULL);
+ clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--branches")) {
for_each_branch_ref(show_reference, NULL);
+ clear_ref_exclusion(&ref_excludes);
continue;
}
if (!prefixcmp(arg, "--tags=")) {
for_each_glob_ref_in(show_reference, arg + 7,
"refs/tags/", NULL);
+ clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--tags")) {
for_each_tag_ref(show_reference, NULL);
+ clear_ref_exclusion(&ref_excludes);
continue;
}
if (!prefixcmp(arg, "--glob=")) {
for_each_glob_ref(show_reference, arg + 7, NULL);
+ clear_ref_exclusion(&ref_excludes);
continue;
}
if (!prefixcmp(arg, "--remotes=")) {
for_each_glob_ref_in(show_reference, arg + 10,
"refs/remotes/", NULL);
+ clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--remotes")) {
for_each_remote_ref(show_reference, NULL);
+ clear_ref_exclusion(&ref_excludes);
+ continue;
+ }
+ if (!prefixcmp(arg, "--exclude=")) {
+ add_ref_exclusion(&ref_excludes, arg + 10);
continue;
}
if (!strcmp(arg, "--show-toplevel")) {