Skip to content

Commit c6d4b6f

Browse files
authored
fix: NRE on commit double-click (#1783)
1 parent 3056287 commit c6d4b6f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ViewModels/Histories.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ public async Task<bool> CheckoutBranchByDecoratorAsync(Models.Decorator decorato
242242

243243
public async Task CheckoutBranchByCommitAsync(Models.Commit commit)
244244
{
245+
if (commit == null)
246+
return;
247+
245248
if (commit.IsCurrentHead)
246249
return;
247250

@@ -265,7 +268,7 @@ public async Task CheckoutBranchByCommitAsync(Models.Commit commit)
265268
continue;
266269

267270
var lb = _repo.Branches.Find(x => x.IsLocal && x.Upstream == rb.FullName);
268-
if (lb.Ahead.Count == 0)
271+
if (lb != null && lb.Behind.Count > 0 && lb.Ahead.Count == 0)
269272
{
270273
if (_repo.CanCreatePopup())
271274
_repo.ShowPopup(new CheckoutAndFastForward(_repo, lb, rb));

0 commit comments

Comments
 (0)