All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Josh Triplett <josh@joshtriplett.org>,
	John Koleszar <jkoleszar@google.com>,
	git@vger.kernel.org, Shawn Pearce <spearce@spearce.org>
Subject: Re: [PATCH] http-backend: respect GIT_NAMESPACE with dumb clients
Date: Thu, 04 Apr 2013 22:34:49 -0700	[thread overview]
Message-ID: <7vobdtee12.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130405025655.GA25970@sigill.intra.peff.net> (Jeff King's message of "Thu, 4 Apr 2013 22:56:55 -0400")

Jeff King <peff@peff.net> 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 <TAB> 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: <target>\n" into a strbuf and send
     it (make sure <target> is without the namespace prefix);

   . Otherwise, HEAD is detached. Prepare "%s\n" % sha1_to_hex(sha1),
     and send it.

  reply	other threads:[~2013-04-05  5:35 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
2013-04-05  5:34                           ` Junio C Hamano [this message]
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=7vobdtee12.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jkoleszar@google.com \
    --cc=josh@joshtriplett.org \
    --cc=peff@peff.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.