Skip to content

fix(gix-traverse): use graph painting for hide() to ensure correct behavior#2408

Merged
Sebastian Thiel (Byron) merged 4 commits intomainfrom
copilot/add-test-for-commit-hiding-issue
Feb 4, 2026
Merged

fix(gix-traverse): use graph painting for hide() to ensure correct behavior#2408
Sebastian Thiel (Byron) merged 4 commits intomainfrom
copilot/add-test-for-commit-hiding-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 3, 2026

The hide() function was lazily traversing hidden commits interleaved with interesting commits during iteration, rather than using proper graph painting. This could potentially include commits that should be hidden if the interesting traversal reached shared ancestors before the hidden traversal painted them.

Changes

  • gix-traverse/src/commit/simple.rs: Refactored hide() to fully traverse all hidden tips and mark all reachable commits as Hidden before returning. This matches git's rev-list --not behavior.

  • New tests: Added hide_with_graph_painting module with tests for:

    • Hidden tip with longer path to shared ancestor
    • Interesting tip with longer path to shared ancestor
    • Both verify output against git rev-list --not

Graph Painting Approach

Graph:
  A(tip) --> shared
           /
  H(hidden) --> X --> Y --> shared

Before: Hidden traversal interleaved with interesting - shared might be 
        returned before H's longer path marks it hidden.

After:  All commits reachable from H are painted hidden upfront.
        Iteration simply skips any Hidden commits.
Original prompt

In gix-traverse there is a way to hide commits, and all their ancestry. But the implementation isn't correct as it's not based on "graph painting" via gix-revwalk, and can easily include commits in the traversal because they have not yet been seen by the tips that are hiding them.
Add a test, using gix-testtools, completely ignoring the test-suite and style in gix-traverse, to reproduce this issue, and try to fix it.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add test to reproduce commit hiding issue in gix-traverse fix(gix-traverse): use graph painting for hide() to ensure correct behavior Feb 3, 2026
@Byron Sebastian Thiel (Byron) force-pushed the copilot/add-test-for-commit-hiding-issue branch from 2e8fccf to 90bbd95 Compare February 3, 2026 20:22
@Byron
Copy link
Copy Markdown
Member

This is terrible for performance, but it at least fixes the long-standing bug, something that should have been done a while ago.
Still I wonder how this can be implemented incrementally, and fear there is no way… .

Copilot AI and others added 4 commits February 3, 2026 21:51
…havior

The hide() function now fully traverses all hidden tips and marks all
reachable commits as Hidden before returning. This "graph painting"
approach ensures correct behavior regardless of graph topology or
traversal order, matching git's behavior.

Previously, hidden commits were traversed lazily during iteration,
interleaved with interesting commits. While this worked in most cases,
the new approach is simpler and more robust.

Added tests to verify correct behavior when:
- Hidden tip has longer path to shared ancestor
- Interesting tip has longer path to shared ancestor

Co-authored-by: Byron <[email protected]>
@Byron Sebastian Thiel (Byron) force-pushed the copilot/add-test-for-commit-hiding-issue branch from 6a5b4e6 to 647d008 Compare February 4, 2026 10:32
@Byron Sebastian Thiel (Byron) marked this pull request as ready for review February 4, 2026 10:32
@Byron Sebastian Thiel (Byron) merged commit 8c88c59 into main Feb 4, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants