diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-12-05 12:59:09 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-05 12:59:09 -0800 |
commit | 10167eb251e177349eebf24650d3c0cc26bd0d75 (patch) | |
tree | 57f7687d96ffe8aa469f1ae345b18f0ab1798a38 /builtin | |
parent | 3576f113cb3f36b9e2b36a84573754a922f2998b (diff) | |
parent | 9dc01bf0631b51dfe497d57942a9085e0808e205 (diff) | |
download | git-10167eb251e177349eebf24650d3c0cc26bd0d75.tar.gz |
Merge branch 'jc/ref-excludes'
People often wished a way to tell "git log --branches" (and "git
log --remotes --not --branches") to exclude some local branches
from the expansion of "--branches" (similarly for "--tags", "--all"
and "--glob=<pattern>"). Now they have one.
* jc/ref-excludes:
rev-parse: introduce --exclude=<glob> to tame wildcards
rev-list --exclude: export add/clear-ref-exclusion and ref-excluded API
rev-list --exclude: tests
document --exclude option
revision: introduce --exclude=<glob> to tame wildcards
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/rev-parse.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 3e8c4cce06..1d9ecafd41 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 @@ -31,6 +33,7 @@ static int abbrev_ref_strict; static int output_sq; static int stuck_long; +static struct string_list *ref_excludes; /* * Some arguments are relevant "revision" arguments, @@ -187,6 +190,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; } @@ -625,32 +630,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, "--local-env-vars")) { |