Skip to content

Commit

Permalink
for some reason the stashRef is invalid and then we run into a nullpt…
Browse files Browse the repository at this point in the history
…r exception
  • Loading branch information
Murmele committed Jun 11, 2024
1 parent ebf2b60 commit 3a845f0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ui/ReferenceModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3a845f0

Please sign in to comment.