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

Two issues with mark_reachable_objects

From
DEDavid Emett <dave@sp4m.net>
Date
Apr 27, 2021, 10:45 UTC
Message-ID
<CAJ-dYSOVx0egnyxJb6ZjgWvEDR=19QPgc70JQ7cXUjUPZ1XDiQ@mail.gmail.com>
Hi all,
I ran into an issue yesterday with a script that effectively does this:
    set -e
    git fetch origin refs/blah/blah
    git checkout FETCH_HEAD
The checkout failed a few times with a "fatal: unable to read tree" error.

I noticed that this only happened when the fetch triggered an automatic GC at the end. After a bit of digging I discovered two separate issues:

1) It seems that FETCH_HEAD is not considered a root by mark_reachable_objects.
2) If the bitmap_git branch in mark_reachable_objects is taken, the mark_recent
   argument is ignored. This doesn't _completely_ break "git prune"'s --expire
   option, as it turns out there is another explicit mtime check in
   prune_object (prune.c). If that check passes this is not propagated to
   referenced objects though. So even if a dangling commit is recent, a prune
   can discard old objects it references.

(1) has been discussed before on this mailing list [1], but it doesn't look like there was a conclusion.

I assume (2) is not intentional, given that "git gc --help" explicitly says "Any object with modification time newer than the --prune date is kept, along with everything reachable from it." Is it safe to just run the mark_recent block after the bitmap_git block? Could add_unseen_recent_objects_to_traversal just be called at the start of the bitmap_git block if mark_recent?

[1] https://lore.kernel.org/git/20160708025948.GA3226@x/
Next: Jeff King
Message 1 of 10 in “Two issues with mark_reachable_objects”
  1. David EmettApr 27, 2021
  2. Jeff KingApr 27, 2021
  3. Jeff KingApr 27, 2021
  4. prune: save reachable-from-recent objects with bitmapsJeff King, Apr 27, 2021
  5. David EmettApr 28, 2021
  6. Jeff KingApr 28, 2021
  7. 0/2 prune: save reachable-from-recent objects with bitmapsJeff King, Apr 28, 2021
  8. 1/2 pack-bitmap: clean up include_check after useJeff King, Apr 28, 2021
  9. 2/2 prune: save reachable-from-recent objects with bitmapsJeff King, Apr 28, 2021
  10. Junio C HamanoApr 29, 2021

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.