Repository navigation
Conversation
git_commit_list_parse() took parents from the commit-graph whenever one was present, while git_commit__parse_ext() applies grafts and shallow roots. In a shallow repository that still has a commit-graph from before it became shallow (git leaves it in place, even across gc), a revwalk went past the shallow boundary. Like git's commit_graph_compatible(), don't use the commit-graph while grafts or shallow roots rewrite parents. The graph's generation numbers come from the real parents too, so the whole graph is skipped rather than only the grafted commits.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A revwalk takes parents from the commit-graph, while
git_commit_lookup()applies shallow roots and grafts, so in a shallow repository with a commit-graph the walk goes past the shallow boundary. git never writes a graph in a shallow repository but keeps an existing one, even acrossgc, so this happens aftergit fetch --depthon a full clone. Withtestrepo.gitandshallowset to be3563a, the walk from HEAD returns 7 commits instead of 2.Like git's
commit_graph_compatible(), the newgit_repository__commit_graph_compatible()rejects the graph when grafts or shallow roots are present (libgit2 has no replace refs).git_commit_list_parse(), the only reader of graph parents and generation numbers, checks it.The new tests (shallow roots and
info/grafts) fail without the change; the full suite passes on Linux. libgit2 1.9 is less affected only because it can't open graphs with generation-v2 data.Not in this PR:
git fetch --unshallowgit itself stops at the old boundary (git commit-graph verify: "parent list for commit ... terminates early"). I can send a separate PR.core.commitGraph.Related: #7487.
Prepared with Claude Code; I reviewed the changes.