mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-23 10:22:13 +08:00
bug: fix int out of bounds for branch names with long numbers (#612)
This commit is contained in:
@@ -51,9 +51,16 @@
|
||||
int result;
|
||||
if (isDigit1 && isDigit2)
|
||||
{
|
||||
int num1 = int.Parse(sub1);
|
||||
int num2 = int.Parse(sub2);
|
||||
result = num1 - num2;
|
||||
// compare numeric values
|
||||
if (sub1.Length == sub2.Length)
|
||||
{
|
||||
// if length is the same, lexicographical comparison is good also for numbers
|
||||
result = string.CompareOrdinal(sub1, sub2);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = sub1.Length.CompareTo(sub2.Length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user