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

git.zx2c4.com/cgit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2016-06-26 00:49:35 +0300
committerRichard Maw <richard.maw@gmail.com>2016-07-13 22:09:37 +0300
commit5817a8f70370c0d41950fb2e7516389866da89b7 (patch)
tree27540f4f14d49d77dbe88287ac1e4efc95e66fa1 /shared.c
parentd25bfb99f9d1f02dcaf1cae3ffce35b9ea5471fd (diff)
Add cgit_for_each_namespaced_ref_in helper
libgit has a for_each_namespaced_ref, but lacks equivalents for just branches, tags or remotes. Rather than implementing all of those helpers, it's more convenient to implement just one that prepends the namespace to the provided ref base. Signed-off-by: Richard Maw <richard.maw@gmail.com>
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/shared.c b/shared.c
index 81a5cd8..54940b3 100644
--- a/shared.c
+++ b/shared.c
@@ -651,3 +651,13 @@ int cgit_get_sha1(const char *name, unsigned char *sha1)
return get_sha1(name, sha1);
}
}
+
+int cgit_for_each_namespaced_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
+{
+ struct strbuf strbuf = STRBUF_INIT;
+ int ret;
+ strbuf_addf(&strbuf, "%s%s", get_git_namespace(), prefix);
+ ret = for_each_ref_in(strbuf.buf, fn, cb_data);
+ strbuf_release(&strbuf);
+ return ret;
+}