From mboxrd@z Thu Jan 1 00:00:00 1970 From: richard.maw at gmail.com (Richard Maw) Date: Mon, 1 Aug 2016 22:35:48 +0100 Subject: [PATCH v3 16/21] Add namespace support to dumb-clone In-Reply-To: <20160801213553.16807-1-richard.maw@gmail.com> References: <20160801213553.16807-1-richard.maw@gmail.com> Message-ID: <20160801213553.16807-17-richard.maw@gmail.com> 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 --- ui-clone.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ui-clone.c b/ui-clone.c index 5f6606a..14380bf 100644 --- a/ui-clone.c +++ b/ui-clone.c @@ -85,7 +85,9 @@ void cgit_clone_info(void) ctx.page.mimetype = "text/plain"; 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 +107,17 @@ void cgit_clone_objects(void) void cgit_clone_head(void) { - send_file(git_path("%s", "HEAD")); + unsigned char unused[20]; + char *ref = cgit_namespaced_resolve_ref("HEAD", 0, unused, NULL); + + if (!ref) { + cgit_print_error_page(404, "Not found", "Not found"); + return; + } + + ctx.page.mimetype = "application/octet-stream"; + ctx.page.filename = xstrdup("HEAD"); + cgit_print_http_headers(); + htmlf("ref: %s\n", strip_namespace(ref)); + free(ref); } -- 2.9.0