Repository navigation
Conversation
git keeps the `shallow` file in the common directory, so all worktrees of a shallow repository share it. libgit2 read and wrote it in the worktree's gitdir instead, so a history walk in a linked worktree of a shallow clone failed with "object not found" at the shallow boundary. git_repository_is_shallow already looks in the common directory since libgit2#7322. Add GIT_REPOSITORY_ITEM_SHALLOW and use it when loading grafts, writing shallow roots and in git_repository_is_shallow. In-memory repositories no longer look for `shallow` in the current directory.
1 task done
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.
git keeps
shallowin the common directory, but libgit2 read and wrote it in the worktree's gitdir. In a linked worktree of a shallow clone, a revwalk therefore fails with "object not found" at the shallow boundary, althoughgit_repository_is_shallowalready reports the worktree as shallow (#7322).This adds
GIT_REPOSITORY_ITEM_SHALLOW(common directory, gitdir as fallback, likeconfig) and uses it inload_grafts,git_repository__shallow_roots_writeandgit_repository_is_shallow. The public enum grows by one value, as it did forGIT_REPOSITORY_ITEM_WORKTREE_CONFIG; a private path helper would also work if you'd rather not touch the API.In-memory repositories have no common directory, so
git_repository_is_shallowused to checkshallowrelative to the current directory; it now returns 0.The new tests in
grafts/shallow.cfail without the change.repo::shallow::worktree_of_shallow_parentwrotexinto the parent'sshallow, which the worktree now parses, so it writes a commit id instead. The full suite passes on Linux.Found while looking into #7487.
Prepared with Claude Code; I reviewed the changes.