Skip to content

Commit c0a08b5

Browse files
gadfly3173biancode
authored andcommitted
fix: NRE on commit double-click (sourcegit-scm#1783)
1 parent c9b28a1 commit c0a08b5

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 is { TrackStatus.Ahead.Count: 0 })
271+
if (lb != null && lb.TrackStatus != null && lb.TrackStatus.Behind.Count > 0 && lb.TrackStatus.Ahead.Count == 0)
269272
{
270273
if (_repo.CanCreatePopup())
271274
_repo.ShowPopup(new CheckoutAndFastForward(_repo, lb, rb));

0 commit comments

Comments
 (0)