Repository navigation
git: stop ^n and ~n parent steps at shallow boundaries - #139
Merged
jsegaran merged 4 commits intoOct 25, 2026
Merged
Conversation
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.
Builds on #134, which builds on #130. Review only the last commit, 1ed860f. Merge after #134.
In a shallow repository,
X^/X~nstep past a boundary that git stops at. gix'srev_parsewalks the parents the commit object names. When another fetch has brought a boundary commit's parent into the object store, gix resolvesbase^to it, while git reportsunknown revision:The same applies to
X~n, to ranges such asold..base^, and to LOG specs, which go through RESOLVE.In a shallow repository,
resolve_onenow rewrites each range endpoint of the form<rev>followed only by^n/~nsteps. It resolves<rev>with gix, walks the steps itself, and replaces the endpoint with the resulting commit. A step off a commit listed in.git/shallowisNotFound.^0stays put,^ntakes the nth parent, and~nfollows first parents. Other forms (^@/^!, which #134 handles;:path;@{…}on its own) still go straight to gix. Repositories that are not shallow are untouched.parent_steps_stop_at_a_shallow_boundarybuilds that clone. It expectsbase^,base~1,head~2andold..base^to beNotFound, andhead^andhead~1^0to resolve tobase. Before this commit,base^resolves toold.Found by differential fuzzing of RESOLVE in shallow clones.
cargo test -p yas-git --test engine,cargo clippy -p yas-git --all-targets -- -D warningsandcargo fmt --checkpass.Tag
@indentto continue the conversation here.