From c6d4b6f7260b94ff6a0ad586697fc866a295b057 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Tue, 2 Sep 2025 09:56:09 +0800 Subject: [PATCH] fix: NRE on commit double-click (#1783) --- src/ViewModels/Histories.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 5c9d67a7..a675f6e2 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -242,6 +242,9 @@ namespace SourceGit.ViewModels public async Task CheckoutBranchByCommitAsync(Models.Commit commit) { + if (commit == null) + return; + if (commit.IsCurrentHead) return; @@ -265,7 +268,7 @@ namespace SourceGit.ViewModels continue; var lb = _repo.Branches.Find(x => x.IsLocal && x.Upstream == rb.FullName); - if (lb.Ahead.Count == 0) + if (lb != null && lb.Behind.Count > 0 && lb.Ahead.Count == 0) { if (_repo.CanCreatePopup()) _repo.ShowPopup(new CheckoutAndFastForward(_repo, lb, rb));