Git development
 help / color / mirror / Atom feed
* [JGIT PATCH 2/1] Honor repack.usedeltabaseoffset when fetching packs
@ 2009-05-01 22:00 Shawn O. Pearce
  2009-05-01 23:19 ` Nicolas Pitre
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2009-05-01 22:00 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

If the local receiving repository has disabled the use of delta base
offset, for example to retain compatibility with older versions of
Git that predate OFS_DELTA, we shouldn't ask for ofs-delta support
when we obtain a pack from the remote server.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---

 I just realized we don't honor this during fetch, and we should.

 .../jgit/transport/BasePackFetchConnection.java    |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
index b75e0ef..b51ce23 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackFetchConnection.java
@@ -49,6 +49,7 @@
 import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.ProgressMonitor;
 import org.spearce.jgit.lib.Ref;
+import org.spearce.jgit.lib.RepositoryConfig;
 import org.spearce.jgit.revwalk.RevCommit;
 import org.spearce.jgit.revwalk.RevCommitList;
 import org.spearce.jgit.revwalk.RevFlag;
@@ -126,10 +127,15 @@
 
 	private boolean includeTags;
 
+	private boolean allowOfsDelta;
+
 	BasePackFetchConnection(final PackTransport packTransport) {
 		super(packTransport);
+
+		final RepositoryConfig cfg = local.getConfig();
 		includeTags = transport.getTagOpt() != TagOpt.NO_TAGS;
 		thinPack = transport.isFetchThin();
+		allowOfsDelta = cfg.getBoolean("repack", "usedeltabaseoffset", true);
 
 		walk = new RevWalk(local);
 		reachableCommits = new RevCommitList<RevCommit>();
@@ -282,7 +288,8 @@ private String enableCapabilities() {
 		final StringBuilder line = new StringBuilder();
 		if (includeTags)
 			includeTags = wantCapability(line, OPTION_INCLUDE_TAG);
-		wantCapability(line, OPTION_OFS_DELTA);
+		if (allowOfsDelta)
+			wantCapability(line, OPTION_OFS_DELTA);
 		multiAck = wantCapability(line, OPTION_MULTI_ACK);
 		if (thinPack)
 			thinPack = wantCapability(line, OPTION_THIN_PACK);
-- 
1.6.3.rc3.212.g8c698

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [JGIT PATCH 2/1] Honor repack.usedeltabaseoffset when fetching packs
  2009-05-01 22:00 [JGIT PATCH 2/1] Honor repack.usedeltabaseoffset when fetching packs Shawn O. Pearce
@ 2009-05-01 23:19 ` Nicolas Pitre
  2009-05-02  0:18   ` [PATCH] honor " Nicolas Pitre
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Pitre @ 2009-05-01 23:19 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Robin Rosenberg, git

On Fri, 1 May 2009, Shawn O. Pearce wrote:

> If the local receiving repository has disabled the use of delta base
> offset, for example to retain compatibility with older versions of
> Git that predate OFS_DELTA, we shouldn't ask for ofs-delta support
> when we obtain a pack from the remote server.

Good point.  I doubt it actually matters in practice or we would have 
heard about some complaints by now.  But for consistency sake I should 
produce a similar patch for C git as well.


Nicolas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] honor repack.usedeltabaseoffset when fetching packs
  2009-05-01 23:19 ` Nicolas Pitre
@ 2009-05-02  0:18   ` Nicolas Pitre
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Pitre @ 2009-05-02  0:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn O. Pearce, git

If the local receiving repository has disabled the use of delta base
offset, for example to retain compatibility with older versions of
Git that predate OFS_DELTA, we shouldn't ask for ofs-delta support
when we obtain a pack from the remote server.

[ issue noticed by Shawn Pearce ]

Signed-off-by: Nicolas Pitre <nico@cam.org>
---

On Fri, 1 May 2009, Nicolas Pitre wrote:

> Good point.  I doubt it actually matters in practice or we would have 
> heard about some complaints by now.  But for consistency sake I should 
> produce a similar patch for C git as well.

Here it is, with commit log stolen from Shawn's JGit patch.

 builtin-fetch-pack.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 5d134be..012d044 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -13,6 +13,7 @@
 static int transfer_unpack_limit = -1;
 static int fetch_unpack_limit = -1;
 static int unpack_limit = 100;
+static int prefer_ofs_delta = 1;
 static struct fetch_pack_args args = {
 	/* .uploadpack = */ "git-upload-pack",
 };
@@ -200,7 +201,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
 				     (args.use_thin_pack ? " thin-pack" : ""),
 				     (args.no_progress ? " no-progress" : ""),
 				     (args.include_tag ? " include-tag" : ""),
-				     " ofs-delta");
+				     (prefer_ofs_delta ? " ofs-delta" : ""));
 		else
 			packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
 		fetching++;
@@ -596,6 +597,11 @@ static struct ref *do_fetch_pack(int fd[2],
 			fprintf(stderr, "Server supports side-band\n");
 		use_sideband = 1;
 	}
+	if (server_supports("ofs-delta")) {
+		if (args.verbose)
+			fprintf(stderr, "Server supports ofs-delta\n");
+	} else
+		prefer_ofs_delta = 0;
 	if (everything_local(&ref, nr_match, match)) {
 		packet_flush(fd[1]);
 		goto all_done;
@@ -648,6 +654,11 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
 		return 0;
 	}
 
+	if (strcmp(var, "repack.usedeltabaseoffset") == 0) {
+		prefer_ofs_delta = git_config_bool(var, value);
+		return 0;
+	}
+
 	return git_default_config(var, value, cb);
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-02  0:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-01 22:00 [JGIT PATCH 2/1] Honor repack.usedeltabaseoffset when fetching packs Shawn O. Pearce
2009-05-01 23:19 ` Nicolas Pitre
2009-05-02  0:18   ` [PATCH] honor " Nicolas Pitre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox