* [JGIT PATCH] Enable ofs-delta during send-pack/receive-pack protocol
@ 2009-05-01 21:56 Shawn O. Pearce
0 siblings, 0 replies; only message in thread
From: Shawn O. Pearce @ 2009-05-01 21:56 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
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@spearce.org>
---
.../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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-01 21:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-01 21:56 [JGIT PATCH] Enable ofs-delta during send-pack/receive-pack protocol Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).