Skip to content
Snippets Groups Projects
Commit 11096a89 authored by Chris Aniszczyk's avatar Chris Aniszczyk Committed by Code Review
Browse files

Merge changes I0d339b9f,I0e6673b8

* changes:
  Favor earlier PackFile instances over later duplicates
  Cleanup duplicated object reuse code in PackWriter
parents 23583e59 a0a52897
No related branches found
No related tags found
No related merge requests found
...@@ -416,10 +416,11 @@ private static Map<String, PackFile> reuseMap(final PackList old) { ...@@ -416,10 +416,11 @@ private static Map<String, PackFile> reuseMap(final PackList old) {
// This should never occur. It should be impossible for us // This should never occur. It should be impossible for us
// to have two pack files with the same name, as all of them // 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 // came out of the same directory. If it does, we promised to
// close any PackFiles we did not reuse, so close the one we // close any PackFiles we did not reuse, so close the second,
// just evicted out of the reuse map. // readers are likely to be actively using the first.
// //
prior.close(); forReuse.put(prior.getPackFile().getName(), prior);
p.close();
} }
} }
return forReuse; return forReuse;
......
...@@ -718,12 +718,11 @@ private void writeObject(final ObjectToPack otp) throws IOException { ...@@ -718,12 +718,11 @@ private void writeObject(final ObjectToPack otp) throws IOException {
final PackedObjectLoader reuse = open(otp); final PackedObjectLoader reuse = open(otp);
if (reuse != null) { if (reuse != null) {
try { try {
if (otp.isDeltaRepresentation()) { if (otp.isDeltaRepresentation())
writeDeltaObjectReuse(otp, reuse); writeDeltaObjectHeader(otp, reuse);
} else { else
writeObjectHeader(otp.getType(), reuse.getSize()); writeObjectHeader(otp.getType(), reuse.getSize());
reuse.copyRawData(out, buf, windowCursor); reuse.copyRawData(out, buf, windowCursor);
}
} finally { } finally {
reuse.endCopyRawData(); reuse.endCopyRawData();
} }
...@@ -773,7 +772,7 @@ private void writeWholeObjectDeflate(final ObjectToPack otp) ...@@ -773,7 +772,7 @@ private void writeWholeObjectDeflate(final ObjectToPack otp)
} while (!deflater.finished()); } while (!deflater.finished());
} }
private void writeDeltaObjectReuse(final ObjectToPack otp, private void writeDeltaObjectHeader(final ObjectToPack otp,
final PackedObjectLoader reuse) throws IOException { final PackedObjectLoader reuse) throws IOException {
if (deltaBaseAsOffset && otp.getDeltaBase() != null) { if (deltaBaseAsOffset && otp.getDeltaBase() != null) {
writeObjectHeader(Constants.OBJ_OFS_DELTA, reuse.getRawSize()); writeObjectHeader(Constants.OBJ_OFS_DELTA, reuse.getRawSize());
...@@ -792,7 +791,6 @@ private void writeDeltaObjectReuse(final ObjectToPack otp, ...@@ -792,7 +791,6 @@ private void writeDeltaObjectReuse(final ObjectToPack otp,
otp.getDeltaBaseId().copyRawTo(buf, 0); otp.getDeltaBaseId().copyRawTo(buf, 0);
out.write(buf, 0, Constants.OBJECT_ID_LENGTH); out.write(buf, 0, Constants.OBJECT_ID_LENGTH);
} }
reuse.copyRawData(out, buf, windowCursor);
} }
private void writeObjectHeader(final int objectType, long dataLength) private void writeObjectHeader(final int objectType, long dataLength)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment