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

Re: [PATCH 4/4] gc: remove broken refs

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 25, 2015, 00:08 UTC
Message-ID
<xmqqr3lnuzqu.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20150924175758.GB15117@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> For the same reasons as in my earlier responses, I think it's dangerous
> to remove broken refs (it makes a small corruption much worse). It seems
> reasonably sane to remove a dangling symref, though if we teach
> for_each_ref to gracefully skip them, then leaving them in place isn't a
> problem.

One thing I wondered was if we can reliably tell between a ref that wanted to be a real ref that records a broken object name and a ref that wanted to be a symbolic ref that points a bogus thing, and if we can't, should we worry about it too much. The former is more serious, as the history behind the commit it wanted to but failed to record is at risk of being pruned.

One case that is clearly safe is "ref: refs/heads/gone"; it is not likely to be the result of attempting to write a real object name gone bad by whatever filesystem corruption. On the other hand, an obviously problematic case is an empty file. We cannot tell if the "broken" ref used to anchor the tip of a real history (which is about to be lost with Dscho's patch 1/4) or was merely pointing at another ref (which will not harm the object database if ignored).

So the rule should be
    If resolve_ref_unsafe_1() says it is a symbolic ref, if
    check_ref_format() is OK with the ref it points at, and if that
    pointee is missing, then it is safe to skip.
All other funnies should trigger the safety.

The collection of "broken and can be removed" refs introduced by 3/4 may also have to take that into account, I think.

Previous: Jeff KingNext: Jeff King
Message 9 of 28 in “Fix gc failure when a remote HEAD goes stale”
  1. 0/4 Fix gc failure when a remote HEAD goes staleJohannes Schindelin, Sep 24, 2015
  2. 1/4 gc: demonstrate failure with stale remote HEADJohannes Schindelin, Sep 24, 2015
  3. 2/4 pack-objects: do not get distracted by stale refsJohannes Schindelin, Sep 24, 2015
  4. Jeff KingSep 24, 2015
  5. 3/4 mark_reachable_objects(): optionally collect broken refsJohannes Schindelin, Sep 24, 2015
  6. Jeff KingSep 24, 2015
  7. 4/4 gc: remove broken refsJohannes Schindelin, Sep 24, 2015
  8. Jeff KingSep 24, 2015
  9. Junio C HamanoSep 25, 2015
  10. Jeff KingSep 25, 2015
  11. 0/4 Fix gc failure when a remote HEAD goes staleJohannes Schindelin, Sep 28, 2015
  12. 1/4 gc: demonstrate failure with stale remote HEADJohannes Schindelin, Sep 28, 2015
  13. 2/4 pack-objects: do not get distracted by broken symrefsJohannes Schindelin, Sep 28, 2015
  14. 3/4 mark_reachable_objects(): optionally collect broken symrefsJohannes Schindelin, Sep 28, 2015
  15. 4/4 gc: remove broken symrefsJohannes Schindelin, Sep 28, 2015
  16. Junio C HamanoSep 28, 2015
  17. Junio C HamanoSep 28, 2015
  18. Johannes SchindelinSep 28, 2015
  19. Junio C HamanoOct 5, 2015
  20. Jeff KingSep 28, 2015
  21. Johannes SchindelinSep 28, 2015
  22. 0/2 Fix gc failure when a remote HEAD goes staleJohannes Schindelin, Oct 6, 2015
  23. 1/2 gc: demonstrate failure with stale remote HEADJohannes Schindelin, Oct 6, 2015
  24. 2/2 pack-objects: do not get distracted by broken symrefsJohannes Schindelin, Oct 6, 2015
  25. Junio C HamanoOct 7, 2015
  26. Johannes SchindelinOct 8, 2015
  27. Junio C HamanoOct 8, 2015
  28. Johannes SchindelinOct 8, 2015

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.