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

Re: Alternates and push

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 8, 2008, 14:56 UTC
Message-ID
<20080908145654.GC10252@spearce.org>
In-Reply-To
<alpine.LNX.1.00.0809080246520.19665@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> wrote:
> On Sun, 7 Sep 2008, Junio C Hamano wrote:
> > 
> > Oops, I forgot to Cc Daniel.  Shawn also CC'ed because he will have the
> > same issue with the smart CGI based http-push he is building.
Not just the smart CGI based http-push thingy.  JGit is impacted
anytime we start talking about network transport.  ;-)
 
Show 10 quoted lines
> > The sending end, however, has a safety to silently ignore malformed refs
> > it learns from the receiving end over the wire.  So the current sender
> > won't work with asterisk in there '*', nor full-pathname, because
> > typically it contains "/.git/" in the string, which would make it an
> > invalid refname to be ignored.
> > 
> > Also, the sending end remembers the objects we have per refname, so
> > sending two records with the same refname pointing at two different
> > objects will not work well either (the current code is loose and does not
> > check duplicates, but that is not a feature by design but is an accident).
Cute. Learn something new every day.

JGit doesn't do the check_ref_format(), but it does do duplicate detection. If the remote side sends us duplicate advertisements JGit freaks out and aborts the transfer. This is largely just a function of JGit hashing the advertised refs for O(1) access later on during processing. We avoid a lot of ugly O(N^2) loops that way.

> I think we should use a really invalid ref name, like "^" or something 
> like that, so that it's clearly not an actually available ref, but just a 
> way for the remote to mention that it has the object, and the remote 
> doesn't have to try to make it unique.
I agree.  How about just calling all of these ".have"?

According to check_ref_format() it fails, so older clients will just ignore it. Attempts by bad clients to push or delete ".have" should also fail automatically in receive-pack's own test at the start of the update() function.

Using a constant name for all instances hides what the underlying alternates really have, in case their branches aren't public, but their databases are. It also makes it easier for hashing clients like JGit to collect these object IDs into a table of known objects, but ignoring the name component.

Sadly no matter what we do here JGit's duplicate detection is in direct opposite behavior with git.git's ignoring check_ref_format() failures. So we'll have to patch JGit no matter what we do.

-- 
Shawn.
Previous: Daniel Barkalow
Message 20 of 20 in “Alternates and push”
  1. Jon SmirlSep 6, 2008
  2. Theodore TsoSep 6, 2008
  3. Junio C HamanoSep 6, 2008
  4. Jon SmirlSep 6, 2008
  5. Shawn O. PearceSep 6, 2008
  6. Petr BaudisSep 9, 2008
  7. Shawn O. PearceSep 9, 2008
  8. Jan HudecSep 7, 2008
  9. Junio C HamanoSep 7, 2008
  10. Jan HudecSep 7, 2008
  11. Junio C HamanoSep 7, 2008
  12. Jan HudecSep 8, 2008
  13. Theodore TsoSep 7, 2008
  14. Junio C HamanoSep 8, 2008
  15. Theodore TsoSep 8, 2008
  16. Junio C HamanoSep 8, 2008
  17. Junio C HamanoSep 8, 2008
  18. Junio C HamanoSep 8, 2008
  19. Daniel BarkalowSep 8, 2008
  20. Shawn O. PearceSep 8, 2008

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.