Conversation
libgit2 applies a shallow clone's cut only through the gitdir of the handle it opened, so a handle rooted at a linked worktree fails on the parents a --depth clone lacks (#2147, #2163). List Repository::graph_ahead_behind under clippy's disallowed-methods so a new history walk cannot bypass the shared helper, and justify the few direct calls that remain: the helper itself, divergence's memo path after is_shallow, and the tests that pin libgit2's behaviour. Route worktree_rebase's behind_count through the helper so it no longer relies on an unrelated Repository::open of the main root. Closes #2176
…entry Move each allow onto the single raw call it justifies instead of the whole function, name the rebase planner as a user of the shared helper, and add a test that fails if clippy.toml stops forbidding a raw graph_ahead_behind.
CoverageTotal: 97.95% ⚪ 0 pp vs Comparing No per-file coverage changes vs 🔇 269 ignored region(s), 0 tolerated region(s)
Patch coveragePatch: 100% (10/10 new lines covered)
|
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 5, 2026
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.
Closes #2176
What changed
clippy.tomlnow listsgit2::Repository::graph_ahead_behindunderdisallowed-methods, with a reason pointing atcrate::git::shallow. A new raw call failscargo clippy, which CI already runs with-D warnings.#[allow(clippy::disallowed_methods)]on the single call, with the reason: the helper's own two walks,divergence's memo path afteris_shallowis false, and the tests that pin libgit2's behaviour.worktree_rebase::behind_countnow goes throughshallow::graph_ahead_behind, so it no longer depends on an unrelatedRepository::openof the main root. Behaviour is unchanged (that handle is a main checkout).clippy_toml_forbids_a_raw_graph_ahead_behind, fails under plaincargo testif theclippy.tomlentry is dropped.shallow.rsmodule docs and the CLAUDE.md worktrees bullet.Chose the lint over a grep-guard because it fails at lint time with a message that teaches the rule and needs no allowlist file. Only
graph_ahead_behindis listed, as the issue suggests;Repository::is_shallowstays unlisted becauseshared_repo.rscalls it on purpose on a common-dir handle.Verification
cargo fmt --check: clean.cargo clippy --all-targets --all-features -- -D warningsandcargo clippy --all-targets -- -D warnings: clean after the rebase. Before the allows were added the lint fired at 8 sites, which confirms it works.cargo test --lib -- git:: worktrees::: 1366 passed, 0 failed.cargo doc --no-deps --document-private-items: builds; no unresolved-link warnings.cargo testsuite and theupdate-snapshotscheck (no CLI surface changed).Review findings
clippy.tomlentry (test added).revwalk/merge_base/Commit::parents. The issue scopes this to the one API that has been bitten, and existing sites (unreachable_commit_countinworktrees.rs,coverage/diff.rs) would need allows or fixes of their own. The module doc records the gap.Follow-ups
main_rootis the parent of the common dir, and for a bare repo with linked worktrees that directory is not a repository (git rev-parsethere fails), sobehind_count'sRepository::openwould returnNoneand the worktree is skipped asNoOntoRef. I confirmed the layout with git but did not run the rebase engine against it. Pre-existing and unchanged here.No departures from the plan comment: #2176 (comment)