Browse Source

ObjectDirectory: Remove last modified check in insertPack

GC explicitly handles the case where a new pack has the same name as an
existing pack due to it containing the exact same set of objects. In
this case, the pack passed to insertPack will have the same name as an
existing pack, but it will also almost certainly have a later mtime than
the existing pack.

The loop in insertPack tried to short-circuit when inserting a new pack,
to avoid walking more of the pack list than necessary. Unfortunately,
this means it will never get to the check for an identical name,
resulting in a duplicate entry for the same PackFile in the pack list.
Remove the short-circuit so that insertPack does not insert a duplicate
entry.

Change-Id: I00711b28594622ad3bd104332334e8a3592cda7f
stable-4.9
Dave Borowitz 7 years ago
parent
commit
5b5c3a2e1d
  1. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java

@ -814,8 +814,6 @@ public class ObjectDirectory extends FileObjectDatabase {
final PackFile[] oldList = o.packs; final PackFile[] oldList = o.packs;
final String name = pf.getPackFile().getName(); final String name = pf.getPackFile().getName();
for (PackFile p : oldList) { for (PackFile p : oldList) {
if (PackFile.SORT.compare(pf, p) < 0)
break;
if (name.equals(p.getPackFile().getName())) if (name.equals(p.getPackFile().getName()))
return; return;
} }

Loading…
Cancel
Save