From 164501db0148a7298ea9465f1f63c6341c9f6a6e Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 4 Aug 2021 09:07:31 +0800 Subject: [PATCH] fix: fix crash reported by https://gitee.com/sourcegit/sourcegit/issues/I43RRK --- src/Commands/Branches.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Commands/Branches.cs b/src/Commands/Branches.cs index 687bb151..bb331615 100644 --- a/src/Commands/Branches.cs +++ b/src/Commands/Branches.cs @@ -39,7 +39,10 @@ namespace SourceGit.Commands { branch.IsLocal = true; } else if (refName.StartsWith(PREFIX_REMOTE, StringComparison.Ordinal)) { var name = refName.Substring(PREFIX_REMOTE.Length); - branch.Remote = name.Substring(0, name.IndexOf('/')); + var shortNameIdx = name.IndexOf('/'); + if (shortNameIdx < 0) return; + + branch.Remote = name.Substring(0, shortNameIdx); branch.Name = name.Substring(branch.Remote.Length + 1); branch.IsLocal = false; } else {