Fix simple commit traversal with hidden tips in single-parent mode #2160
+214
−65
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.
Fixes #2159
Problem
Simple commit traversal with hidden tips doesn't work at all with single-parent mode. When using
Parents::First
with hidden commits, the traversal would fail to properly handle the combination of:The issue was that the current implementation would either:
Solution
This PR implements the fix described in the issue: "traverse all parents then, but return (and mark) only the ones that are actually along the line of first parents, passed down via bitflag."
Key Changes
Replaced
CommitState
enum with bitflags: Changed from a simple enum to bitflags that can track multiple properties:INTERESTING
: The commit may be returnedHIDDEN
: The commit should not be returnedON_FIRST_PARENT_LINE
: The commit is on the first-parent lineUpdated parent processing logic: Modified
insert_into_seen_and_next
andinsert_into_seen_and_queue
to:Fixed commit return logic: Updated the commit filtering to:
Example
Testing
The fix ensures that single-parent traversal with hidden tips now works correctly by maintaining the semantics of both features: only following the first-parent line for returned commits while still traversing all branches to properly handle hidden commit marking.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.