Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo in ManagedGit ParentEnumerator.MoveNext causes incorrect behavior and ArgumentOutOfRangeException #694

Closed
GlebChili opened this issue Nov 23, 2021 · 1 comment · Fixed by #693
Labels
Milestone

Comments

@GlebChili
Copy link
Contributor

Implementation of the ParentEnumerator.MoveNext method in ManagedGit contains a small typo, which leads to incorrect behavior and System.ArgumentOutOfRangeException while iterating when number of commit's parents is greater than 2:

_ => this.owner.AdditionalParents?.Count >= this.position - 2,

A non-strict inequality there should be replaced with a strict one.

I have opened a PR #693 which fixes the typo and adds a corresponding test. I'm testing against a real commit from mono/mono repository: mono/mono@ab39e8a.
It is a quite old commit from the times when merge strategy allowed commits to have three parents.

@AArnott
Copy link
Collaborator

AArnott commented Nov 23, 2021

Great find. Incidentally, merges still allow more than two parents. I create them occasionally, but not enough apparently to hit this bug myself.

@AArnott AArnott added the bug label Nov 23, 2021
@AArnott AArnott added this to the v3.4 milestone Nov 23, 2021
@AArnott AArnott closed this as completed Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants