From: Junio C Hamano Date: Fri, 05 Apr 2013 05:34:49 GMT Subject: Re: [PATCH] http-backend: respect GIT_NAMESPACE with dumb clients Message-ID: <7vobdtee12.fsf@alter.siamese.dyndns.org> In-Reply-To: <20130405025655.GA25970@sigill.intra.peff.net> Jeff King writes: > 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); > +} You identified the right place to patch, but I think we need a bit more than this. The show_text_ref() function gives "SHA-1 refname". It is likely that the dumb client will ignore the trailing part of that output, but let's avoid a hack that we would not want see other implementations imitate. One advantage dumb clients has over smart ones is that they can read HEAD that is a textual symref from a dumb server and learn which branch is the default one (remote.c::guess_remote_head()) without guessing. I think this function should: - Turn "HEAD" into a namespaced equivalent; - Run resolve_ref() on the result of the above; - Is it a symbolic ref? . If it is, then format "ref: \n" into a strbuf and send it (make sure is without the namespace prefix); . Otherwise, HEAD is detached. Prepare "%s\n" % sha1_to_hex(sha1), and send it.