aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-04-26 16:54:48 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-04-26 17:29:10 -0700
commiteeed0abd1626eb972059252bdc1c68b5bb8faf78 (patch)
treec25278adf3542e85d3540593b33225ad1cb68998
parent4ef96296f7cbd748cf46a6c6fba045e355915158 (diff)
downloadjgit-eeed0abd1626eb972059252bdc1c68b5bb8faf78.tar.gz
jgit-eeed0abd1626eb972059252bdc1c68b5bb8faf78.zip
Cleanup duplicated object reuse code in PackWriter
This reuse line was identical between the two branches related to reusing a delta, or reusing a whole object. Either way they reuse the body of the object as-is. So just make that a common function after the header is written. Change-Id: I0e6673b8e813c8c08c594ea2ba546fd366339d5d Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/PackWriter.java12
1 files changed, 5 insertions, 7 deletions
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)