diff options
author | Chris Aniszczyk <caniszczyk@gmail.com> | 2010-05-03 03:39:47 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2010-05-03 03:39:47 -0400 |
commit | 11096a89a55852d18f340ffa53af1e17be5550c3 (patch) | |
tree | a35f6e6a0791143b0c6bbe0b86ccc196f527910f /org.eclipse.jgit | |
parent | 23583e59bbd707d4f10e15af7c1c4f2874e13685 (diff) | |
parent | a0a52897ed3fb66ff8a7e1737bf854042f77f0ce (diff) | |
download | jgit-11096a89a55852d18f340ffa53af1e17be5550c3.tar.gz jgit-11096a89a55852d18f340ffa53af1e17be5550c3.zip |
Merge changes I0d339b9f,I0e6673b8
* changes:
Favor earlier PackFile instances over later duplicates
Cleanup duplicated object reuse code in PackWriter
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java | 7 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java | 12 |
2 files changed, 9 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java index a8d6dda066..8f96ef5f06 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectDirectory.java @@ -416,10 +416,11 @@ public class ObjectDirectory extends ObjectDatabase { // This should never occur. It should be impossible for us // to have two pack files with the same name, as all of them // came out of the same directory. If it does, we promised to - // close any PackFiles we did not reuse, so close the one we - // just evicted out of the reuse map. + // close any PackFiles we did not reuse, so close the second, + // readers are likely to be actively using the first. // - prior.close(); + forReuse.put(prior.getPackFile().getName(), prior); + p.close(); } } return forReuse; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java index b30e5f7c23..0c8210f646 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java @@ -718,12 +718,11 @@ public class PackWriter { final PackedObjectLoader reuse = open(otp); if (reuse != null) { try { - if (otp.isDeltaRepresentation()) { - writeDeltaObjectReuse(otp, reuse); - } else { + if (otp.isDeltaRepresentation()) + writeDeltaObjectHeader(otp, reuse); + else writeObjectHeader(otp.getType(), reuse.getSize()); - reuse.copyRawData(out, buf, windowCursor); - } + reuse.copyRawData(out, buf, windowCursor); } finally { reuse.endCopyRawData(); } @@ -773,7 +772,7 @@ public class PackWriter { } while (!deflater.finished()); } - private void writeDeltaObjectReuse(final ObjectToPack otp, + private void writeDeltaObjectHeader(final ObjectToPack otp, final PackedObjectLoader reuse) throws IOException { if (deltaBaseAsOffset && otp.getDeltaBase() != null) { writeObjectHeader(Constants.OBJ_OFS_DELTA, reuse.getRawSize()); @@ -792,7 +791,6 @@ public class PackWriter { otp.getDeltaBaseId().copyRawTo(buf, 0); out.write(buf, 0, Constants.OBJECT_ID_LENGTH); } - reuse.copyRawData(out, buf, windowCursor); } private void writeObjectHeader(final int objectType, long dataLength) |