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:
authorJunio C Hamano <gitster@pobox.com>2011-08-18 04:35:38 +0400
committerJunio C Hamano <gitster@pobox.com>2011-08-18 04:35:38 +0400
commit6ed547b53b90bebd2371b086b83b416b22b243b2 (patch)
treed0b9cf755a58c5b9f6f460936e240bb44dd6274a /refs.c
parent6dd5622f68157f471c4f784e8c41f39e8c5163fc (diff)
parentbf7930caa0da2fbd6def59a54608ac494c272197 (diff)
Merge branch 'js/ref-namespaces'
* js/ref-namespaces: ref namespaces: tests ref namespaces: documentation ref namespaces: Support remote repositories via upload-pack and receive-pack ref namespaces: infrastructure Fix prefix handling in ref iteration functions
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/refs.c b/refs.c
index 3a8789d385..6f313a9e0c 100644
--- a/refs.c
+++ b/refs.c
@@ -584,7 +584,7 @@ int read_ref(const char *ref, unsigned char *sha1)
static int do_one_ref(const char *base, each_ref_fn fn, int trim,
int flags, void *cb_data, struct ref_list *entry)
{
- if (strncmp(base, entry->name, trim))
+ if (prefixcmp(entry->name, base))
return 0;
if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
@@ -728,12 +728,12 @@ int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
int for_each_ref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref(NULL, "refs/", fn, 0, 0, cb_data);
+ return do_for_each_ref(NULL, "", fn, 0, 0, cb_data);
}
int for_each_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref(submodule, "refs/", fn, 0, 0, cb_data);
+ return do_for_each_ref(submodule, "", fn, 0, 0, cb_data);
}
int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
@@ -782,6 +782,31 @@ int for_each_replace_ref(each_ref_fn fn, void *cb_data)
return do_for_each_ref(NULL, "refs/replace/", fn, 13, 0, cb_data);
}
+int head_ref_namespaced(each_ref_fn fn, void *cb_data)
+{
+ struct strbuf buf = STRBUF_INIT;
+ int ret = 0;
+ unsigned char sha1[20];
+ int flag;
+
+ strbuf_addf(&buf, "%sHEAD", get_git_namespace());
+ if (resolve_ref(buf.buf, sha1, 1, &flag))
+ ret = fn(buf.buf, sha1, flag, cb_data);
+ strbuf_release(&buf);
+
+ return ret;
+}
+
+int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
+{
+ struct strbuf buf = STRBUF_INIT;
+ int ret;
+ strbuf_addf(&buf, "%srefs/", get_git_namespace());
+ ret = do_for_each_ref(NULL, buf.buf, fn, 0, 0, cb_data);
+ strbuf_release(&buf);
+ return ret;
+}
+
int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
const char *prefix, void *cb_data)
{
@@ -819,7 +844,7 @@ int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)
int for_each_rawref(each_ref_fn fn, void *cb_data)
{
- return do_for_each_ref(NULL, "refs/", fn, 0,
+ return do_for_each_ref(NULL, "", fn, 0,
DO_FOR_EACH_INCLUDE_BROKEN, cb_data);
}