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 2e8da8fc9..a3e9430b1 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 @@ -430,9 +430,14 @@ public void prune(Set objectsToKeep) throws IOException, return; // delete all candidates which have survived: these are unreferenced - // loose objects - for (File f : deletionCandidates.values()) - f.delete(); + // loose objects. Make a last check, though, to avoid deleting objects + // that could have been referenced while the candidates list was being + // built (by an incoming push, for example). + for (File f : deletionCandidates.values()) { + if (f.lastModified() < expireDate) { + f.delete(); + } + } repo.getObjectDatabase().close(); }