git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] http-backend: respect GIT_NAMESPACE with dumb clients

From
Jeff King <peff@peff.net>
Date
Apr 5, 2013, 02:56 UTC
Message-ID
<20130405025655.GA25970@sigill.intra.peff.net>
In-Reply-To
<20130405023516.GA32290@leaf>
On Thu, Apr 04, 2013 at 07:35:16PM -0700, Josh Triplett wrote:
Show 12 quoted lines
> > Including the HEAD ref in the advertisement from /info/refs ends up
> > duplicating it, since the dumb client unconditionally fetches the file
> > /HEAD to use as the that ref. I think the right thing to do is
> > generate the correct /HEAD using head_ref_namespaced(), rather than
> > returning the bare file $GIT_DIR/HEAD, but I'm not 100% sure how HEAD
> > and namespaces interact, since I haven't been able to produce a repo
> > with a different HEAD in a namespace. Can you verify this approach?
> 
> Semantically, every namespace should act like a completely independent
> repository, which includes having its own independent HEAD.  A namespace
> should *not* see the HEAD of the entire repository, only its own
> namespaced HEAD.

Yeah, that makes sense. I think we'd want something like the (totally untested) patch below. And the tests I provided for t5551 should be amended to set up a HEAD within the namespace, should make the resulting clone non-bare, and should confirm that we check out the correct HEAD.

diff --git a/http-backend.c b/http-backend.c
index 8144f3a..84ba7f9 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -376,6 +376,14 @@ static int show_text_ref(const char *name, const unsigned char *sha1,
 	return 0;
 }
 
+static void get_head(char *arg)
+{
+	struct strbuf buf = STRBUF_INIT;
+	head_ref_namespaced(show_text_ref, &buf);
+	send_strbuf("text/plain", &buf);
+	strbuf_release(&buf);
+}
+
 static void get_info_refs(char *arg)
 {
 	const char *service_name = get_parameter("service");
@@ -520,7 +528,7 @@ static struct service_cmd {
 	const char *pattern;
 	void (*imp)(char *);
 } services[] = {
-	{"GET", "/HEAD$", get_text_file},
+	{"GET", "/HEAD$", get_head },
 	{"GET", "/info/refs$", get_info_refs},
 	{"GET", "/objects/info/alternates$", get_text_file},
 	{"GET", "/objects/info/http-alternates$", get_text_file},
Previous: Josh TriplettNext: Junio C Hamano
Message 16 of 26 in “http-backend: respect GIT_NAMESPACE with dumb clients”
  1. http-backend: respect GIT_NAMESPACE with dumb clientsJohn Koleszar, Mar 28, 2013
  2. Junio C HamanoMar 28, 2013
  3. Josh TriplettMar 28, 2013
  4. Junio C HamanoMar 28, 2013
  5. John KoleszarMar 28, 2013
  6. Junio C HamanoMar 28, 2013
  7. http-backend: respect GIT_NAMESPACE with dumb clientsJohn Koleszar, Apr 3, 2013
  8. Jeff KingApr 3, 2013
  9. Jeff KingApr 3, 2013
  10. Junio C HamanoApr 3, 2013
  11. John KoleszarApr 4, 2013
  12. http-backend: respect GIT_NAMESPACE with dumb clientsJohn Koleszar, Apr 4, 2013
  13. Junio C HamanoApr 4, 2013
  14. John KoleszarApr 5, 2013
  15. Josh TriplettApr 5, 2013
  16. Jeff KingApr 5, 2013
  17. Junio C HamanoApr 5, 2013
  18. Jeff KingApr 5, 2013
  19. John KoleszarApr 6, 2013
  20. http-backend: respect GIT_NAMESPACE with dumb clientsJohn Koleszar, Apr 10, 2013
  21. Junio C HamanoApr 10, 2013
  22. Jeff KingApr 10, 2013
  23. Thomas RastApr 8, 2013
  24. Jeff KingApr 8, 2013
  25. John KoleszarApr 9, 2013
  26. Junio C HamanoApr 3, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.