fix(graph): solve commit graph sort transitivity issue #12344
fix(graph): solve commit graph sort transitivity issue #12344Byron merged 3 commits intogitbutlerapp:masterfrom
Conversation
|
@foxfirecodes is attempting to deploy a commit to the GitButler Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical transitivity violation in the commit graph's sorting logic that caused panics during graph traversal after force-pushing. The bug occurred when the comparison function for GenThenTime mixed commits with and without generation numbers, leading to inconsistent ordering that violated Rust's sort contract.
Changes:
- Fixed the
GenThenTime::cmpimplementation to treatNonegeneration asu32::MAX(matching Git'sGENERATION_NUMBER_INFINITYconvention), ensuring a total order - Updated documentation to clearly explain the rationale for using
u32::MAXas a sentinel value - Added comprehensive test coverage for the transitivity fix and various generation/time combinations
|
This looks like a reasonable change to me. I've started CI on it. Out of an abundance of caution I would also like to defer to @Byron before merging since he has the most knowledge of this part of the code. |
|
Thanks a lot for setting up the fix! I will merge it shortly after a quick hands-on. |
3670a61 to
340805b
Compare
- enable running unit-tests - refactor `walk.rs` also to enable more refactoring in future.
340805b to
997e66d
Compare
Byron
left a comment
There was a problem hiding this comment.
Thanks so much for the fix - I think it's good, too.
Nothing else breaks, the tests actually test for this property and the old version fails them.
Let's bring it in.
DISCLAIMER: this fix was written by Claude Code. it looks reasonable to me but i am severely lacking in the context of how the commit graph works to know if this solution is right. just sharing this to maybe save you some time, take with a grain of salt
🧢 Changes
this PR solves a sort transitivity issue when constructing the commit graph. it also adds some unit tests to avoid this issue cropping up in the future
☕️ Reasoning
see #12343 for more context, but tl;dr after a force push my commit graph ended up in a state where Git Butler panicked trying to parse. this boils down to a violation of the rules of transitivity when it comes to sorting. i will share the explanation that Claude Code gave me as it does a better job explaining than me lol:
🎫 Affected issues
Fixes: #12343