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

Re: Alternates and push

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 7, 2008, 19:18 UTC
Message-ID
<7v8wu3n4t1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<7vhc8rn5sl.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 19 quoted lines
> Jan Hudec <bulb@ucw.cz> writes:
> ...
>> Why is this a *mis*design? Couldn't push be fixed by redesigning it's
>> protocol along the lines of:
>>  - clients sends a list of sha1s it wants to push, from the tip down
>>  - server stops it when it sees an object it has -- this check can be done
>>    against the object store without having a ref for it.
>
> Because your second step is *BROKEN*.
>
> Think of a case where an earlier commit walker started fetching into that
> "server" end, which got newer commits and their associated objects first
> and then older ones, and then got killed before reaching to the objects it
> already had.  In such a case, the commit walker will *not* update the refs
> on the server end (and for a very good reason).
>
> After that, the server end would have:
>
>  * refs that point at some older commits, all objects from whom are
s/from whom/reachable from which/;
>    guaranteed to be in the repository (that's the "ref" guarantee);
>
>  * newer commits and their objects, but if you follow them you will hit
>    some objects that are *NOT* in the repository.
To visualize, the server object store and refs would be like this:
    ---o---o---A...x...x...x...x...o---o---X
               ^ ref

Commits 'x' are all missing because the commit walker fetched commit X, inspected its tree and got the necessary tree and blob objects, went back to get X's parent, did the same, then its parent, attempted to do the same but got killed before connecting the history fully to A.

If you accepted history on top of X before guaranteeing that you have everything reachable from X already in this round of push will give you this:

    ---o---o---A...x...x...x...x...o---o---X---o---o---Y
               ^ ref =========== (wrong) ============> ^ ref

and if you update the ref to point at Y, then you cannot satisfy requests from other people who want the history that leads to Y, because somewhere between A and X there are commit that you do not even have to begin with.

So you may even be able accept objects between X..Y, but you cannot update the ref from A to Y after accepting such a push, which is pointless.

You could try a variant of it to unbreak your trick, though. When you see an object that you have, say 'X' above, you traverse down from there until reaching some ref (in this case, A) and make sure that you have everything in between (not just commits but also associated trees and blobs that are needed). This is quite similar to what is happening when the commit walker says "walk deadbeef..." in its progress output. So it _could_ be done, but it would be somewhat expensive.

Previous: Jan HudecNext: Jan Hudec
Message 11 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.