diff --git src/git.cpp src/git.cpp
index f125bb8..450f960 100644
--- src/git.cpp
+++ src/git.cpp
@@ -603,6 +603,9 @@ const QString Git::getLaneParent(SCRef fromSHA, int laneNum) {
 	for (int idx = rs->orderIdx - 1; idx >= 0; idx--) {
 
 		const Rev* r = revLookup(revData->revOrder[idx]);
+		if (!r) {
+			continue;
+		}
 		if (laneNum >= r->lanes.count())
 			return "";
 
@@ -636,6 +639,9 @@ const QStringList Git::getChildren(SCRef parent) {
         QStringList::iterator itC(children.begin());
         for ( ; itC != children.end(); ++itC) {
 		const Rev* r = revLookup(*itC);
+		if (!r) {
+			continue;
+		}
 		(*itC).prepend(QString("%1 ").arg(r->orderIdx, 6));
 	}
         children.sort();
@@ -662,7 +668,7 @@ MyProcess* Git::getDiff(SCRef sha, QObject* receiver, SCRef diffToSha, bool comb
 		runCmd.append(combined ? "-c " : "-C -m "); // TODO rename for combined
 
         const Rev* r = revLookup(sha);
-        if (r->parentsCount() == 0)
+        if (r && r->parentsCount() == 0)
             runCmd.append("--root ");
 
 		runCmd.append(diffToSha + " " + sha); // diffToSha could be empty
@@ -895,7 +901,7 @@ bool Git::isContiguous(const QStringList &revs)
 	if (revs.count() == 1) return true;
 	for (QStringList::const_iterator it=revs.begin(), end=revs.end()-1; it!=end; ++it) {
 		const Rev* c = revLookup(*it);
-		if (!c->parents().contains(*(it+1))) return false;
+		if (!c || !c->parents().contains(*(it+1))) return false;
 	}
 	return true;
 }
@@ -923,11 +929,15 @@ bool Git::isSameFiles(SCRef tree1Sha, SCRef tree2Sha) {
 const QStringList Git::getDescendantBranches(SCRef sha, bool shaOnly) {
 
 	QStringList tl;
-	const Rev* r = revLookup(sha);
+	Rev* r = (Rev*)revLookup(sha);
 	if (!r || (r->descBrnMaster == -1))
 		return tl;
 
-	const QVector<int>& nr = revLookup(revData->revOrder[r->descBrnMaster])->descBranches;
+	r = (Rev*)revLookup(revData->revOrder[r->descBrnMaster]);
+	if (!r) {
+		return tl;
+	}
+	const QVector<int>& nr = r->descBranches;
 
 	for (int i = 0; i < nr.count(); i++) {
 
@@ -953,7 +963,7 @@ const QStringList Git::getDescendantBranches(SCRef sha, bool shaOnly) {
 const QStringList Git::getNearTags(bool goDown, SCRef sha) {
 
 	QStringList tl;
-	const Rev* r = revLookup(sha);
+	Rev* r = (Rev*)revLookup(sha);
 	if (!r)
 		return tl;
 
@@ -961,8 +971,11 @@ const QStringList Git::getNearTags(bool goDown, SCRef sha) {
 	if (nearRefsMaster == -1)
 		return tl;
 
-	const QVector<int>& nr = goDown ? revLookup(revData->revOrder[nearRefsMaster])->descRefs :
-	                                  revLookup(revData->revOrder[nearRefsMaster])->ancRefs;
+	r = (Rev*)revLookup(revData->revOrder[nearRefsMaster]);
+	if (!r)
+		return tl;
+	const QVector<int>& nr = goDown ? r->descRefs :
+	                                  r->ancRefs;
 
 	for (int i = 0; i < nr.count(); i++) {
 
@@ -2579,7 +2592,7 @@ void Git::loadFileNames() {
 
                 if (!revsFiles.contains(*it)) {
                         const Rev* c = revLookup(*it);
-                        if (c->parentsCount() == 1) { // skip initials and merges
+                        if (c && c->parentsCount() == 1) { // skip initials and merges
                                 diffTreeBuf.append(*it).append('\n');
                                 revCnt++;
                         }
@@ -2730,8 +2743,10 @@ int Git::addChunk(FileHistory* fh, const QByteArray& ba, int start) {
                 if (loadingUnAppliedPatches) {
 
                         Rev* c = const_cast<Rev*>(revLookup(sha, fh));
-                        c->isUnApplied = true;
-                        c->lanes.append(UNAPPLIED);
+				    if (c) {
+					    c->isUnApplied = true;
+					    c->lanes.append(UNAPPLIED);
+				    }
 
                 } else if (patchesStillToFind > 0 || !isMainHistory(fh)) { // try to avoid costly lookup
 
@@ -2739,14 +2754,16 @@ int Git::addChunk(FileHistory* fh, const QByteArray& ba, int start) {
                         if (rf && (rf->type & APPLIED)) {
 
                                 Rev* c = const_cast<Rev*>(revLookup(sha, fh));
-                                c->isApplied = true;
-                                if (isMainHistory(fh)) {
-                                        patchesStillToFind--;
-                                        if (patchesStillToFind == 0)
-                                                // any rev will be discarded until
-                                                // firstNonStGitPatch arrives
-                                                firstNonStGitPatch = c->parent(0);
-                                }
+						  if (c) {
+							  c->isApplied = true;
+							  if (isMainHistory(fh)) {
+									patchesStillToFind--;
+									if (patchesStillToFind == 0)
+										   // any rev will be discarded until
+										   // firstNonStGitPatch arrives
+										   firstNonStGitPatch = c->parent(0);
+							  }
+						  }
                         }
                 }
         }
@@ -2787,7 +2804,7 @@ void Git::setLane(SCRef sha, FileHistory* fh) {
 
                 const ShaString& curSha = shaVec[i];
                 Rev* r = const_cast<Rev*>(revLookup(curSha, fh));
-                if (r->lanes.count() == 0)
+                if (r && r->lanes.count() == 0)
                         updateLanes(*r, *l, curSha);
 
                 if (curSha == ss)
@@ -2950,6 +2967,9 @@ void Git::updateDescMap(const Rev* r,uint idx, QHash<QPair<uint, uint>, bool>& d
         if (r->descRefsMaster != -1) {
 
                 const Rev* tmp = revLookup(revData->revOrder[r->descRefsMaster]);
+			 if (!tmp) {
+				 return;
+			 }
                 const QVector<int>& nr = tmp->descRefs;
 
                 for (int i = 0; i < nr.count(); i++) {
@@ -3078,6 +3098,9 @@ void Git::indexTree() {
                 bool isT = (type & TAG);
 
                 const Rev* r = revLookup(ro[i]);
+			 if (!r) {
+				 continue;
+			 }
 
                 if (isB) {
                         Rev* rr = const_cast<Rev*>(r);
@@ -3116,6 +3139,9 @@ void Git::indexTree() {
 
                 const Rev* r = revLookup(ro[i]);
                 bool isTag = checkRef(ro[i], TAG);
+			 if (!r) {
+				 continue;
+			 }
 
                 if (isTag) {
                         Rev* rr = const_cast<Rev*>(r);
