From a1899beb8816fe3c0cd20b754040298a61c6ef8c Mon Sep 17 00:00:00 2001 From: Gadfly Date: Tue, 2 Sep 2025 01:52:09 +0800 Subject: [PATCH] fix: NRE on commit double-click --- 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 5c9d67a76..a675f6e22 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -242,6 +242,9 @@ public async Task CheckoutBranchByDecoratorAsync(Models.Decorator decorato public async Task CheckoutBranchByCommitAsync(Models.Commit commit) { + if (commit == null) + return; + if (commit.IsCurrentHead) return; @@ -265,7 +268,7 @@ public async Task CheckoutBranchByCommitAsync(Models.Commit commit) 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));