From: richard.maw at gmail.com (Richard Maw)
Subject: [PATCH 11/16] Add namespace support to dumb-clone
Date: Fri, 15 Jul 2016 23:59:57 +0100 [thread overview]
Message-ID: <20160715230002.29547-12-richard.maw@gmail.com> (raw)
In-Reply-To: <20160715230002.29547-1-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 <richard.maw at gmail.com>
---
ui-clone.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
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"));
+ }
}
--
2.9.0
next prev parent reply other threads:[~2016-07-15 22:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 22:59 [PATCH 00/16] [V2] Add namespace support to cgit richard.maw
2016-07-15 22:59 ` [PATCH 01/16] Fix archive generation richard.maw
2016-07-15 22:59 ` [PATCH 02/16] Add a wrapper for get_sha1 called cgit_get_sha1 richard.maw
2016-07-15 22:59 ` [PATCH 03/16] Parse repo.namespace richard.maw
2016-07-15 22:59 ` [PATCH 04/16] Print out parsed namespace on request richard.maw
2016-07-15 22:59 ` [PATCH 05/16] Set GIT_NAMESPACE when repo.namespace is provided richard.maw
2016-07-15 22:59 ` [PATCH 06/16] Look up refs in namespace with cgit_get_sha1 richard.maw
2016-07-29 14:32 ` Jason
[not found] ` <CAB2VqoZZiAsWpA1YbXARLaq8VMcWLJyXDG6-w0ag1JBOp_0M0Q@mail.gmail.com>
2016-07-29 16:54 ` richard.maw
2016-07-30 15:21 ` richard.maw
2016-07-15 22:59 ` [PATCH 07/16] Guess the default branch based on current namespace richard.maw
2016-07-29 14:36 ` Jason
2016-07-29 15:42 ` richard.maw
2016-07-15 22:59 ` [PATCH 08/16] Add cgit_for_each_namespaced_ref_in helper richard.maw
2016-07-15 22:59 ` [PATCH 09/16] Find the default branch based on the contents of the namespace richard.maw
2016-07-15 22:59 ` [PATCH 10/16] Only display refs in current namespace richard.maw
2016-07-15 22:59 ` richard.maw [this message]
2016-07-29 14:38 ` [PATCH 11/16] Add namespace support to dumb-clone Jason
2016-07-15 22:59 ` [PATCH 12/16] Display notes from namespace richard.maw
2016-07-29 14:44 ` Jason
2016-07-29 15:56 ` richard.maw
2016-07-15 22:59 ` [PATCH 13/16] Add documentation for repo.namespace richard.maw
2016-07-29 14:48 ` Jason
2016-07-29 15:59 ` richard.maw
2016-07-15 23:00 ` [PATCH 14/16] Allow agefile to be set per-repository richard.maw
2016-07-15 23:00 ` [PATCH 15/16] Update contrib script to update agefiles per namespace richard.maw
2016-07-29 14:51 ` Jason
2016-07-29 16:01 ` richard.maw
2016-07-15 23:00 ` [PATCH 16/16] Add documentation for repo.agefile richard.maw
2016-07-15 23:10 ` [PATCH 00/16] [V2] Add namespace support to cgit richard.maw
2016-07-28 16:40 ` richard.maw
2016-07-28 21:20 ` Jason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160715230002.29547-12-richard.maw@gmail.com \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).