aboutsummaryrefslogtreecommitdiffstats
path: root/ui-clone.c
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2016-06-25 23:24:20 +0100
committerRichard Maw <richard.maw@gmail.com>2016-07-13 20:09:37 +0100
commitc8d5732367593ee4a29cd7c2f05fc17a748db9c4 (patch)
tree15e15ba8a4b8f112d8cb99038c4e1074608976fe /ui-clone.c
parent44efabfc5e36a92f060bcdb470fcf4a1814579f9 (diff)
downloadcgit-c8d5732367593ee4a29cd7c2f05fc17a748db9c4.tar.gz
cgit-c8d5732367593ee4a29cd7c2f05fc17a748db9c4.tar.bz2
cgit-c8d5732367593ee4a29cd7c2f05fc17a748db9c4.zip
Add namespace support to dumb-clone
This requires namespacing the HEAD symbolic ref and the list of refs. Sending HEAD required some tweaking, since the file itself refers to a namespaced ref, but we want to provide the ref with its namespace stripped off. Signed-off-by: Richard Maw <richard.maw@gmail.com>
Diffstat (limited to 'ui-clone.c')
-rw-r--r--ui-clone.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/ui-clone.c b/ui-clone.c
index 5f6606a..c610ed2 100644
--- a/ui-clone.c
+++ b/ui-clone.c
@@ -86,6 +86,9 @@ void cgit_clone_info(void)
ctx.page.filename = "info/refs";
cgit_print_http_headers();
for_each_ref(print_ref_info, NULL);
+ /* NOTE: we pass an empty prefix because we want to enumerate everything
+ not just all refs under $namespace/refs/ */
+ cgit_for_each_namespaced_ref_in("", print_ref_info, NULL);
}
void cgit_clone_objects(void)
@@ -105,5 +108,23 @@ void cgit_clone_objects(void)
void cgit_clone_head(void)
{
- send_file(git_path("%s", "HEAD"));
+ if (get_git_namespace()) {
+ unsigned char unused[20];
+ char *namespaced_head = NULL;
+ const char *ref;
+ namespaced_head = mkpathdup("%sHEAD", get_git_namespace());
+ /* NOTE: RESOLVE_REF_NO_RECURSE is required to prevent it resolving HEAD
+ into a ref outside of the namespace. */
+ ref = resolve_ref_unsafe(namespaced_head, RESOLVE_REF_NO_RECURSE, unused, NULL);
+ if (!ref) {
+ cgit_print_error_page(404, "Not found", "Not found");
+ free(namespaced_head);
+ return;
+ }
+ cgit_print_http_headers();
+ htmlf("ref: %s\n", strip_namespace(ref));
+ free(namespaced_head);
+ } else {
+ send_file(git_path("%s", "HEAD"));
+ }
}