From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH] Enable ofs-delta during send-pack/receive-pack protocol
Date: Fri, 1 May 2009 14:56:08 -0700 [thread overview]
Message-ID: <1241214968-28743-1-git-send-email-spearce@spearce.org> (raw)
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
reply other threads:[~2009-05-01 21:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1241214968-28743-1-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).