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

Re: [PATCHv9 3/4] ref namespaces: Support remote repositories via upload-pack and receive-pack

From
Josh Triplett <josh@joshtriplett.org>
Date
Jul 7, 2011, 05:31 UTC
Message-ID
<20110707053122.GA1798@leaf>
In-Reply-To
<7vy60bkzmf.fsf@alter.siamese.dyndns.org>
On Wed, Jul 06, 2011 at 11:55:36AM -0700, Junio C Hamano wrote:
Show 48 quoted lines
> Josh Triplett <josh@joshtriplett.org> writes:
> 
> > Change upload-pack and receive-pack to use the namespace-prefixed refs
> > when working with the repository, and use the unprefixed refs when
> > talking to the client, maintaining the masquerade.  This allows
> > clone, pull, fetch, and push to work with a suitably configured
> > GIT_NAMESPACE.
> >
> > With appropriate configuration, this also allows http-backend to expose
> > namespaces as multiple repositories with different paths.  This only
> > requires setting GIT_NAMESPACE, which http-backend passes through to
> > upload-pack and receive-pack.
> >
> > Signed-off-by: Josh Triplett <josh@joshtriplett.org>
> > Signed-off-by: Jamey Sharp <jamey@minilop.net>
> > ---
> >  builtin/receive-pack.c |   37 +++++++++++++++++++++++++++++++------
> >  upload-pack.c          |   15 ++++++++-------
> >  2 files changed, 39 insertions(+), 13 deletions(-)
> >
> > diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> > index e1a687a..2d36378 100644
> > --- a/builtin/receive-pack.c
> > +++ b/builtin/receive-pack.c
> > @@ -120,9 +120,17 @@ static int show_ref(const char *path, const unsigned char *sha1, int flag, void
> >  	return 0;
> >  }
> >  
> > +static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *cb_data)
> > +{
> > +	path = strip_namespace(path);
> > +	if (!path)
> > +		path = ".have";
> > +	return show_ref(path, sha1, flag, cb_data);
> 
> At the first glance, this felt somewhat unoptimal as it forbids us from
> stuffing fake "ref" entries other than ".have" via the add_extra_ref()
> interface, and I wondered if it would make sense to do something like this
> instead:
> 
> 	const char *ns_path = strip_namespace(path);
>         if (!ns_path)
>         	ns_path = path;
> 	return show_ref(ns_path, sha1, flag, cb_data);
> 
> But that is flawed, and I think your patch does the right thing.  The
> justification is a bit subtle [*1*] and I think it needs to be explained
> in a comment around here, not just in the 0/4 cover letter message.
Will do.  How does the following coment sound?
/* We advertise refs outside our current namespace as .have refs, so
 * that the client can use them to minimize data transfer but will
 * otherwise ignore them. */
- Josh Triplett
Previous: Junio C HamanoNext: Josh Triplett
Message 6 of 7 in “[PATCHv9 0/4] ref namespaces”
  1. Josh TriplettJul 5, 2011
  2. 1/4 Fix prefix handling in ref iteration functionsJosh Triplett, Jul 5, 2011
  3. 2/4 ref namespaces: infrastructureJosh Triplett, Jul 5, 2011
  4. 3/4 ref namespaces: Support remote repositories via upload-pack and receive-packJosh Triplett, Jul 5, 2011
  5. Junio C HamanoJul 6, 2011
  6. Josh TriplettJul 7, 2011
  7. 4/4 ref namespaces: documentationJosh Triplett, Jul 5, 2011

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.