summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2013-03-18 13:20:11 +0100
committerChristian Halstrick <christian.halstrick@sap.com>2013-03-19 11:23:45 +0100
commit67b98d5d40d3d531c2383bbc13d7d93abc7d1b8e (patch)
treeb8b4d1f5c6eb19fd401e4e66e8c22574da8dc7a0 /org.eclipse.jgit
parentf32b8612433e499090c76ded014dd5e94322b786 (diff)
downloadjgit-67b98d5d40d3d531c2383bbc13d7d93abc7d1b8e.tar.gz
jgit-67b98d5d40d3d531c2383bbc13d7d93abc7d1b8e.zip
Make GC more robust against corrupt reflogs
With JGit it is possible to write reflog entries where new objectid and old objectid is null. Such reflogs cause FileRepository GC to crash because it doesn't expect the new objectid to be null. One case where this happened is in Gerrit's allProjects repo. In the same way as we expect the old objectid to be potentially null we should also ignore null values in the new objectid column. Change-Id: Icf666c7ef803179b84306ca8deb602369b8df16e
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index 67bb664b5b..22fa827044 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -555,7 +555,9 @@ public class GC {
for (ReflogEntry e : rlEntries) {
if (e.getWho().getWhen().getTime() < minTime)
break;
- ret.add(e.getNewId());
+ ObjectId newId = e.getNewId();
+ if (newId != null && !ObjectId.zeroId().equals(newId))
+ ret.add(newId);
ObjectId oldId = e.getOldId();
if (oldId != null && !ObjectId.zeroId().equals(oldId))
ret.add(oldId);