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

Re: [PATCH v2 4/5] index-pack, unpack-objects: add --not-so-strict for connectivity check

From
Junio C Hamano <gitster@pobox.com>
Date
May 3, 2013, 06:55 UTC
Message-ID
<7vbo8szh4y.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vk3ngzi6o.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes:
>
>> What do you mean by "partial history"? Do we have dangling pointers
>> after doing that commit walker?
>
> "^C" will leave the objects and it is safe because it will not
> update refs.
>
> But your code that does not verify the full connectivity from such
> an object (that is outside the transferred pack) to the rest of the
> history will then make the resulting repository broken, if you
> update your ref to point at such an object, no?  Ading a single
> has_sha1_file() only verifies that single object, not the history
> behind it.
Let's illustrate.  Imagine your project as a whole has this history:
---A---B---C---D---E

When you cloned, it only had up to A, so that is what you have. Then you try http walker, which slurps E, wants to go to D and dig down, but after fetching E, some trees and blobs in E, and fetching D, but before completing D' trees and blobs, your ISP cuts you off.

You have these in your object store:
---A           D---E

but your ref is pointing at A, because we promise that we make sure full connectivity before we update the ref, and even if you have commits D and E, the associated trees, blobs, and commits behind this subpart of the history are missing.

Now you try to fetch from another mirror over the pack transport. You advertise that you have A (but you do not advertise E, because your refs do not point at it), and you expect all objects that are listed in "rev-list --objects A..E" to be gien to you.

Unfortunately, the mirror is broken, in that it only packs the objects that appear in "rev-list --objects A..B", but still tells you that it is sending objects to complete history leading to E.

Your object store would have objects like this after this transfer:
---A---B       D---E

You may still have commits D and E unpruned, but are missing C, and trees and blobs that are needed in D or E.

You have to walk the history from E and list the necessary objects yourself, running has_sha1_file() on all of them, to prove that you have everything needed, and the only things you can trust are your refs (in this case, A).

If you verify that all the objects in the transferred pack are complete, and also verify that the object the transfer proposes to update your ref to is _in_ that pack, then you can detect a mirror that is broken and only sends objects for A..B, but that does not actually solve the issue. Imagine another broken mirror that instead sends objects for E. E, its trees and all its blobs may be in the pack and the only outgoing link from that pack may be a pointer out of E pointing at D. You happen to _have_ it in your object store, but that does not mean you can update your ref to E (remember, you do not have trees and blobs to complete D, or the history behind it).

The current check is implemented in the way we currently do it, _not_ because we were stupid and did not realize the optimization possibility (in other words, what your patch proposes is not new), but because we rejected this approach because it was not safe.

Previous: Junio C HamanoNext: Duy Nguyen
Message 21 of 35 in “check_everything_connected replacement”
  1. 0/4 check_everything_connected replacementNguyễn Thái Ngọc Duy, Mar 31, 2013
  2. 1/4 fetch-pack: save shallow file before fetching the packNguyễn Thái Ngọc Duy, Mar 31, 2013
  3. Junio C HamanoApr 1, 2013
  4. Duy NguyenApr 5, 2013
  5. 2/4 index-pack: remove dead code (it should never happen)Nguyễn Thái Ngọc Duy, Mar 31, 2013
  6. 3/4 index-pack, unpack-objects: add --not-so-strict for connectivity checkNguyễn Thái Ngọc Duy, Mar 31, 2013
  7. 4/4 Use --not-so-strict on all pack transfer for connectivity checkNguyễn Thái Ngọc Duy, Mar 31, 2013
  8. Junio C HamanoApr 1, 2013
  9. 0/5 check_everything_connected replacementNguyễn Thái Ngọc Duy, May 1, 2013
  10. 1/5 clone: let the user know when check_everything_connected is runNguyễn Thái Ngọc Duy, May 1, 2013
  11. 2/5 fetch-pack: prepare updated shallow file before fetching the packNguyễn Thái Ngọc Duy, May 1, 2013
  12. Junio C HamanoMay 1, 2013
  13. Duy NguyenMay 2, 2013
  14. 3/5 index-pack: remove dead code (it should never happen)Nguyễn Thái Ngọc Duy, May 1, 2013
  15. 4/5 index-pack, unpack-objects: add --not-so-strict for connectivity checkNguyễn Thái Ngọc Duy, May 1, 2013
  16. Junio C HamanoMay 1, 2013
  17. Duy NguyenMay 2, 2013
  18. Junio C HamanoMay 2, 2013
  19. Duy NguyenMay 3, 2013
  20. Junio C HamanoMay 3, 2013
  21. Junio C HamanoMay 3, 2013
  22. Duy NguyenMay 3, 2013
  23. Eric SunshineMay 3, 2013
  24. 5/5 Use --not-so-strict on all pack transfer for connectivity checkNguyễn Thái Ngọc Duy, May 1, 2013
  25. 0/4 check_everything_connected replacementNguyễn Thái Ngọc Duy, May 3, 2013
  26. 1/4 clone: let the user know when check_everything_connected is runNguyễn Thái Ngọc Duy, May 3, 2013
  27. 2/4 fetch-pack: prepare updated shallow file before fetching the packNguyễn Thái Ngọc Duy, May 3, 2013
  28. Eric SunshineMay 3, 2013
  29. Junio C HamanoMay 7, 2013
  30. Duy NguyenMay 26, 2013
  31. 3/4 index-pack: remove dead code (it should never happen)Nguyễn Thái Ngọc Duy, May 3, 2013
  32. 4/4 clone: open a shortcut for connectivity checkNguyễn Thái Ngọc Duy, May 3, 2013
  33. Eric SunshineMay 3, 2013
  34. Junio C HamanoMay 3, 2013
  35. Duy NguyenMay 4, 2013

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.