Skip to content

Handle shallow graph traversal cutoffs#13589

Draft
Byron wants to merge 3 commits intomasterfrom
shallow-walk
Draft

Handle shallow graph traversal cutoffs#13589
Byron wants to merge 3 commits intomasterfrom
shallow-walk

Conversation

@Byron
Copy link
Copy Markdown
Collaborator

@Byron Byron commented Apr 30, 2026

Summary

Handle shallow clone boundaries in but-graph traversal and expose explicit cutoff conditions for graph debug output. The StGit patch handle-shallow-cutoffs marks shallow boundary commits, stops traversal at their grafted parents, and replaces the old boolean early-end API with CutoffCondition bitflags.

Context

This session focused on making shallow clone traversal stop at Git's shallow boundary without presenting that stop as an ordinary traversal limit cutoff. The implementation follows the gix shallow-boundary pattern: read repo.shallow_commits(), yield boundary commits, and avoid queueing their recorded parents.

The prior is_early_end_of_traversal() boolean was replaced with traversal_condition() -> Option<CutoffCondition>, where conditions can include limit cutoffs, natural first/root commits, and shallow boundaries. Debug rendering now shows each applicable condition distinctly, while stack projection keeps its existing user-facing early-end behavior for limit cutoffs only.

Snapshots were updated for the newly visible root-commit debug marker, and a regression test creates a real file:// shallow clone because plain local-path clones ignore --depth.

Validation

  • cargo fmt --package but-graph --package but-testsupport
  • cargo test -p but-graph

Disclosure

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

User Prompts

in but-graph, add a test that creates a shallow clone of a repository, and assert that the traversal yields a result up to the boundary. These boundary commits should be marked with a specific flag so they don't look like a natural graph traversal cutoff as the traversal is done or limited. /Users/byron/dev/github.com/GitoxideLabs/gitoxide/gix/src/revision/walk.rs:287-318 shows how to use the shallow boundary.

Turn is_early_end_of_traversal() into traversal_condition() -> Option<Condition>, with None being what 'nothing special', and Some(Condition) encoding: early end due to limits, 'the first commit' which has no parents, and 'shallow boundary'. Make it a bitflag as it can contain multiple conditions at once. For now, most callers can stick to their existing behaviour and use .is_none()/is_some() to get a boolean, only debug should show all conditions that apply.

Also incorporate the shallow-handling from the first plan. The CutoffCondition (formerly Condition) is just a part of it.

Implement the plan.

Add explicit cutoff conditions to but-graph traversal so debug output can distinguish natural roots, limit cutoffs, and shallow boundaries. Mark commits listed in the repository shallow boundary file and stop queueing their grafted parents so shallow clones traverse up to the boundary without treating it as a normal limit cutoff.

This change replaces the boolean early-end traversal API with CutoffCondition bitflags, preserves existing stack projection behavior for limit cutoffs, updates statistics and debug helpers, and adds a file:// shallow-clone regression test.

Validation:
- cargo test -p but-graph
@github-actions github-actions Bot added the rust Pull requests that update Rust code label Apr 30, 2026
codex added 2 commits May 1, 2026 07:19
The rust-lint GitHub Actions job failed because clippy::single-char-add-str rejects push_str() with single-character string literals in cutoff debug rendering.

Use String::push() for the root and shallow boundary marker characters. This keeps the debug output unchanged while satisfying clippy.

Validation:
- cargo clippy -p but-graph --all-targets -- -D warnings
- cargo test -p but-graph
The new first-commit cutoff condition is rendered in debug graph output. Workspace rust-test also exercises but-rebase inline snapshots that include graph roots, so update those expected snapshots to include the root marker.

Validation:
- cargo test -p but-rebase --test rebase graph_rebase
- cargo test -p but-rebase --test rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants