|
|
@ -618,22 +618,19 @@ public class GC { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Set<ObjectId> listNonHEADIndexObjects() |
|
|
|
private Set<ObjectId> listNonHEADIndexObjects() |
|
|
|
throws CorruptObjectException, IOException { |
|
|
|
throws CorruptObjectException, IOException { |
|
|
|
RevWalk revWalk = null; |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
if (repo.getIndexFile() == null) |
|
|
|
if (repo.getIndexFile() == null) |
|
|
|
return Collections.emptySet(); |
|
|
|
return Collections.emptySet(); |
|
|
|
} catch (NoWorkTreeException e) { |
|
|
|
} catch (NoWorkTreeException e) { |
|
|
|
return Collections.emptySet(); |
|
|
|
return Collections.emptySet(); |
|
|
|
} |
|
|
|
} |
|
|
|
TreeWalk treeWalk = new TreeWalk(repo); |
|
|
|
try (TreeWalk treeWalk = new TreeWalk(repo)) { |
|
|
|
try { |
|
|
|
|
|
|
|
treeWalk.addTree(new DirCacheIterator(repo.readDirCache())); |
|
|
|
treeWalk.addTree(new DirCacheIterator(repo.readDirCache())); |
|
|
|
ObjectId headID = repo.resolve(Constants.HEAD); |
|
|
|
ObjectId headID = repo.resolve(Constants.HEAD); |
|
|
|
if (headID != null) { |
|
|
|
if (headID != null) { |
|
|
|
revWalk = new RevWalk(repo); |
|
|
|
try (RevWalk revWalk = new RevWalk(repo)) { |
|
|
|
treeWalk.addTree(revWalk.parseTree(headID)); |
|
|
|
treeWalk.addTree(revWalk.parseTree(headID)); |
|
|
|
revWalk.dispose(); |
|
|
|
} |
|
|
|
revWalk = null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
treeWalk.setFilter(TreeFilter.ANY_DIFF); |
|
|
|
treeWalk.setFilter(TreeFilter.ANY_DIFF); |
|
|
@ -662,10 +659,6 @@ public class GC { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} finally { |
|
|
|
|
|
|
|
if (revWalk != null) |
|
|
|
|
|
|
|
revWalk.dispose(); |
|
|
|
|
|
|
|
treeWalk.release(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -689,8 +682,9 @@ public class GC { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
PackWriter pw = new PackWriter((pconfig == null) ? new PackConfig(repo) : pconfig, repo.newObjectReader()); |
|
|
|
try (PackWriter pw = new PackWriter( |
|
|
|
try { |
|
|
|
(pconfig == null) ? new PackConfig(repo) : pconfig, |
|
|
|
|
|
|
|
repo.newObjectReader())) { |
|
|
|
// prepare the PackWriter
|
|
|
|
// prepare the PackWriter
|
|
|
|
pw.setDeltaBaseAsOffset(true); |
|
|
|
pw.setDeltaBaseAsOffset(true); |
|
|
|
pw.setReuseDeltaCommits(false); |
|
|
|
pw.setReuseDeltaCommits(false); |
|
|
@ -810,7 +804,6 @@ public class GC { |
|
|
|
} |
|
|
|
} |
|
|
|
return repo.getObjectDatabase().openPack(realPack); |
|
|
|
return repo.getObjectDatabase().openPack(realPack); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
pw.release(); |
|
|
|
|
|
|
|
if (tmpPack != null && tmpPack.exists()) |
|
|
|
if (tmpPack != null && tmpPack.exists()) |
|
|
|
tmpPack.delete(); |
|
|
|
tmpPack.delete(); |
|
|
|
for (File tmpExt : tmpExts.values()) { |
|
|
|
for (File tmpExt : tmpExts.values()) { |
|
|
|