git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Josh Triplett <josh@joshtriplett.org>
Cc: John Koleszar <jkoleszar@google.com>,
	Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org, Shawn Pearce <spearce@spearce.org>
Subject: Re: [PATCH] http-backend: respect GIT_NAMESPACE with dumb clients
Date: Thu, 4 Apr 2013 22:56:55 -0400	[thread overview]
Message-ID: <20130405025655.GA25970@sigill.intra.peff.net> (raw)
In-Reply-To: <20130405023516.GA32290@leaf>

On Thu, Apr 04, 2013 at 07:35:16PM -0700, Josh Triplett wrote:

> > 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},

  reply	other threads:[~2013-04-05  2:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28  4:58 [PATCH] http-backend: respect GIT_NAMESPACE with dumb clients John Koleszar
2013-03-28  6:02 ` Junio C Hamano
2013-03-28 15:49   ` Josh Triplett
2013-03-28 14:43 ` Junio C Hamano
     [not found]   ` <CAAvHm8NAqVHLz1wjNN-3ocpYzWfO-PDo0PAJ6pZO7KrMkhJ6Jw@mail.gmail.com>
2013-03-28 15:54     ` John Koleszar
2013-03-28 16:46       ` Junio C Hamano
2013-04-03 15:52       ` John Koleszar
2013-04-03 16:10         ` Jeff King
2013-04-03 16:16           ` Jeff King
2013-04-03 18:05             ` Junio C Hamano
2013-04-04 15:34               ` John Koleszar
2013-04-04 16:01                 ` John Koleszar
2013-04-04 17:25                   ` Junio C Hamano
2013-04-05  1:22                     ` John Koleszar
2013-04-05  2:35                       ` Josh Triplett
2013-04-05  2:56                         ` Jeff King [this message]
2013-04-05  5:34                           ` Junio C Hamano
2013-04-05  5:43                             ` Jeff King
2013-04-06  0:54                               ` John Koleszar
2013-04-10  0:55                                 ` [PATCH v4] " John Koleszar
2013-04-10  1:09                                   ` Junio C Hamano
2013-04-10  4:18                                   ` Jeff King
2013-04-08 21:25                   ` [PATCH] " Thomas Rast
2013-04-08 21:45                     ` Jeff King
2013-04-09 22:13                       ` John Koleszar
2013-04-03 18:04         ` Junio C Hamano

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=20130405025655.GA25970@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jkoleszar@google.com \
    --cc=josh@joshtriplett.org \
    --cc=spearce@spearce.org \
    /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).