In "allow OFS_DELTA objects during a push" Nicolas Pitre taught C git how to enable OBJ_OFS_DELTA usage in a pack file created on a client, to be processed by receive-pack on the server side. This creates a smaller pack file during transfer, as the OFS_DELTA format uses less per-delta header space than the classical REF_DELTA. If the receiving peer is going to just store the pack to disk, this would also produce a smaller on-disk pack file. In his change, Nico tied the server side enablement of the capability to the server's repack.usedeltabaseoffset setting, which can be set to false in a repository that needs to service direct access clients that are old to understand OFS_DELTA. We do the same here in JGit to match semantics. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../jgit/transport/BasePackPushConnection.java | 6 ++++++ .../org/spearce/jgit/transport/ReceivePack.java | 9 +++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java index 07e8cb9..1117109 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java @@ -78,12 +78,16 @@ static final String CAPABILITY_DELETE_REFS = "delete-refs"; + static final String CAPABILITY_OFS_DELTA = "ofs-delta"; + private final boolean thinPack; private boolean capableDeleteRefs; private boolean capableReport; + private boolean capableOfsDelta; + private boolean sentCommand; private boolean writePack; @@ -180,6 +184,7 @@ private String enableCapabilities() { final StringBuilder line = new StringBuilder(); capableReport = wantCapability(line, CAPABILITY_REPORT_STATUS); capableDeleteRefs = wantCapability(line, CAPABILITY_DELETE_REFS); + capableOfsDelta = wantCapability(line, CAPABILITY_OFS_DELTA); if (line.length() > 0) line.setCharAt(0, '\0'); return line.toString(); @@ -202,6 +207,7 @@ private void writePack(final Map<String, RemoteRefUpdate> refUpdates, } writer.setThin(thinPack); + writer.setDeltaBaseAsOffset(capableOfsDelta); writer.preparePack(newObjects, remoteObjects); writer.writePack(out); } diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java index 89ddafe..f75a01a 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java @@ -77,6 +77,8 @@ static final String CAPABILITY_DELETE_REFS = BasePackPushConnection.CAPABILITY_DELETE_REFS; + static final String CAPABILITY_OFS_DELTA = BasePackPushConnection.CAPABILITY_OFS_DELTA; + /** Database we write the stored objects into. */ private final Repository db; @@ -95,6 +97,8 @@ /** Should an incoming transfer permit non-fast-forward requests? */ private boolean allowNonFastForwards; + private boolean allowOfsDelta; + /** Identity to record action as within the reflog. */ private PersonIdent refLogIdent; @@ -145,6 +149,7 @@ public ReceivePack(final Repository into) { allowDeletes = !cfg.getBoolean("receive", "denydeletes", false); allowNonFastForwards = !cfg.getBoolean("receive", "denynonfastforwards", false); + allowOfsDelta = cfg.getBoolean("repack", "usedeltabaseoffset", true); preReceive = PreReceiveHook.NULL; postReceive = PostReceiveHook.NULL; } @@ -455,6 +460,10 @@ private void sendAdvertisedRefs() throws IOException { m.append(CAPABILITY_DELETE_REFS); m.append(' '); m.append(CAPABILITY_REPORT_STATUS); + if (allowOfsDelta) { + m.append(' '); + m.append(CAPABILITY_OFS_DELTA); + } m.append(' '); writeAdvertisedRef(m); } -- 1.6.3.rc3.212.g8c698 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html