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));