mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
bug: fix int out of bounds for branch names with long numbers (#612)
This commit is contained in:
parent
6c390d2f04
commit
a363f67f31
1 changed files with 10 additions and 3 deletions
|
@ -51,9 +51,16 @@
|
||||||
int result;
|
int result;
|
||||||
if (isDigit1 && isDigit2)
|
if (isDigit1 && isDigit2)
|
||||||
{
|
{
|
||||||
int num1 = int.Parse(sub1);
|
// compare numeric values
|
||||||
int num2 = int.Parse(sub2);
|
if (sub1.Length == sub2.Length)
|
||||||
result = num1 - num2;
|
{
|
||||||
|
// 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
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue