Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorIlari Liusvaara <ilari.liusvaara@elisanet.fi>2010-01-20 12:48:26 +0300
committerJunio C Hamano <gitster@pobox.com>2010-01-20 23:30:25 +0300
commitb09fe971dea73ff6f5296ce533a566114b23ca4e (patch)
tree69b2da8e23b89af69575aa4de550479dc87652ff /refs.c
parentd08bae7e221727e26baab984b792854b842130d7 (diff)
rev-parse --branches/--tags/--remotes=pattern
Since local branch, tags and remote tracking branch namespaces are most often used, add shortcut notations for globbing those in manner similar to --glob option. With this, one can express the "what I have but origin doesn't?" as: 'git log --branches --not --remotes=origin' Original-idea-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index 34fff75b0d..503a8c2bd0 100644
--- a/refs.c
+++ b/refs.c
@@ -690,15 +690,18 @@ int for_each_replace_ref(each_ref_fn fn, void *cb_data)
return do_for_each_ref("refs/replace/", fn, 13, 0, cb_data);
}
-int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
+int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
+ const char *prefix, void *cb_data)
{
struct strbuf real_pattern = STRBUF_INIT;
struct ref_filter filter;
const char *has_glob_specials;
int ret;
- if (prefixcmp(pattern, "refs/"))
+ if (!prefix && prefixcmp(pattern, "refs/"))
strbuf_addstr(&real_pattern, "refs/");
+ else if (prefix)
+ strbuf_addstr(&real_pattern, prefix);
strbuf_addstr(&real_pattern, pattern);
has_glob_specials = strpbrk(pattern, "?*[");
@@ -719,6 +722,11 @@ int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
return ret;
}
+int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
+{
+ return for_each_glob_ref_in(fn, pattern, NULL, cb_data);
+}
+
int for_each_rawref(each_ref_fn fn, void *cb_data)
{
return do_for_each_ref("refs/", fn, 0,