aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index 645de2704e..98a1c8ca4b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -607,7 +607,8 @@ public class DirCache {
final LockFile tmp = myLock;
requireLocked(tmp);
try {
- writeTo(new SafeBufferedOutputStream(tmp.getOutputStream()));
+ writeTo(liveFile.getParentFile(),
+ new SafeBufferedOutputStream(tmp.getOutputStream()));
} catch (IOException err) {
tmp.unlock();
throw err;
@@ -620,7 +621,7 @@ public class DirCache {
}
}
- void writeTo(final OutputStream os) throws IOException {
+ void writeTo(File dir, final OutputStream os) throws IOException {
final MessageDigest foot = Constants.newMessageDigest();
final DigestOutputStream dos = new DigestOutputStream(os, foot);
@@ -670,14 +671,18 @@ public class DirCache {
}
if (writeTree) {
- final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
- tree.write(tmp, bb);
- bb.close();
-
- NB.encodeInt32(tmp, 0, EXT_TREE);
- NB.encodeInt32(tmp, 4, (int) bb.length());
- dos.write(tmp, 0, 8);
- bb.writeTo(dos, null);
+ TemporaryBuffer bb = new TemporaryBuffer.LocalFile(dir, 5 << 20);
+ try {
+ tree.write(tmp, bb);
+ bb.close();
+
+ NB.encodeInt32(tmp, 0, EXT_TREE);
+ NB.encodeInt32(tmp, 4, (int) bb.length());
+ dos.write(tmp, 0, 8);
+ bb.writeTo(dos, null);
+ } finally {
+ bb.destroy();
+ }
}
writeIndexChecksum = foot.digest();
os.write(writeIndexChecksum);