From 593d791b8496d338800a375fc1b5f125777bdd8a Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 23:17:29 +0200 Subject: [PATCH] if stashRef is invalid it should not checked further. Description: In a previous libgit2 version there was an assert and return if the stash is invalid, but in newer once it is not --- src/ui/ReferenceModel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/ReferenceModel.cpp b/src/ui/ReferenceModel.cpp index 5dbd29b3d..306edb35c 100644 --- a/src/ui/ReferenceModel.cpp +++ b/src/ui/ReferenceModel.cpp @@ -106,7 +106,8 @@ void ReferenceModel::update() { // Add bottom references. const bool stashOnCommit = !mCommit.isValid() || - mRepo.stashRef().annotatedCommit().commit() == mCommit; + (mRepo.stashRef().isValid() && + mRepo.stashRef().annotatedCommit().commit() == mCommit); if ((mKinds & ReferenceView::Stash) && stashOnCommit) { if (git::Reference stash = mRepo.stashRef()) branches.append(stash); @@ -180,8 +181,9 @@ QModelIndex ReferenceModel::firstBranch() { // use the first valid ref after the invalid ref but only // it is not the stash if (ref.refs.count() > 1 && - ref.refs.at(1).annotatedCommit().commit() != - mRepo.stashRef().annotatedCommit().commit()) + (!mRepo.stashRef().isValid() || + ref.refs.at(1).annotatedCommit().commit() != + mRepo.stashRef().annotatedCommit().commit())) return createIndex(1, 0, ReferenceType::Branches); } else if (ref.refs.count() > 0) return createIndex(0, 0, ReferenceType::Branches);