diff --git a/src/index/Index.cpp b/src/index/Index.cpp index 317995144..929099ead 100644 --- a/src/index/Index.cpp +++ b/src/index/Index.cpp @@ -260,9 +260,13 @@ QList Index::commits(const QList &postings) const { // Look up commits. QSet commits; foreach (const Posting &posting, postings) { - // FIXME: Remove deleted commits on write. - if (git::Commit commit = mRepo.lookupCommit(mIds.at(posting.id))) - commits.insert(commit); + // If we fail this check, then the index is mismatching the repo + // The FIXME below might be the cause of that + if (posting.id < mIds.size()) { + // FIXME: Remove deleted commits on write. + if (git::Commit commit = mRepo.lookupCommit(mIds.at(posting.id))) + commits.insert(commit); + } } return commits.values();