File tempDir = Files.createTempDirectory("temp_git_repo").toFile();
System.out.println("Clone Dir: " + tempDir.toString());
Git git = null;
try {
WindowCacheConfig config = new WindowCacheConfig();
config.setPackedGitMMAP(true);
WindowCache.reconfigure(config);
git = Git.cloneRepository()
.setDirectory(tempDir).call();
} finally {
if(git != null) {
git.getRepository().close();
}
FileUtils.delete(tempDir, FileUtils.RECURSIVE | FileUtils.RETRY);
}
Exception in thread "main" java.io.IOException: Could not delete file C:\Users\YOUNGS~1\AppData\Local\Temp\temp_git_repo1803971009233318937\.git\objects\pack\pack-1edb465f57d546b7c6343b02c151cb3bdd68ef87.pack
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:142)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:126)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:126)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:126)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:126)
at TestGitClone.main(TestGitClone.java:28)