git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 4/5] Fix BaseFetchPackConnection's output of selected capabilities

From
Shawn O. Pearce <spearce@spearce.org>
Date
Dec 23, 2008, 22:56 UTC
Message-ID
<1230073007-17337-5-git-send-email-spearce@spearce.org>
In-Reply-To
<1230073007-17337-4-git-send-email-spearce@spearce.org>

When we output the first "have ..." line for an upload-pack server process we need to dump "have $id $cap1 $cap2 ..", where there is a space between the SHA-1 $id and the first capability name $cap1. If we don't dump that space we run into errors with our own version of upload-pack not being able to parse the SHA-1 out of the line, as the line was split incorrectly.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../spearce/jgit/transport/BasePackConnection.java |    3 +--
 .../jgit/transport/BasePackPushConnection.java     |    2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
index e9df30e..c9232ce 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
@@ -207,8 +207,7 @@ protected boolean isCapableOf(final String option) {
 	protected boolean wantCapability(final StringBuilder b, final String option) {
 		if (!isCapableOf(option))
 			return false;
-		if (b.length() > 0)
-			b.append(' ');
+		b.append(' ');
 		b.append(option);
 		return true;
 	}
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 17f6915..a078d7e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackPushConnection.java
@@ -181,7 +181,7 @@ private String enableCapabilities() {
 		capableReport = wantCapability(line, CAPABILITY_REPORT_STATUS);
 		capableDeleteRefs = wantCapability(line, CAPABILITY_DELETE_REFS);
 		if (line.length() > 0)
-			line.insert(0, '\0');
+			line.setCharAt(0, '\0');
 		return line.toString();
 	}
 
-- 
1.6.1.rc4.301.g5497a
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 5 of 6 in “Add "jgit upload-pack" for fetch service”
  1. 0/5 Add "jgit upload-pack" for fetch serviceShawn O. Pearce, Dec 23, 2008
  2. 1/5 Sort Ref objects by OrigName and not NameShawn O. Pearce, Dec 23, 2008
  3. 2/5 Permit subclass of ObjectId (e.g. RevObject) when calling PackWriterShawn O. Pearce, Dec 23, 2008
  4. 3/5 Implement "jgit upload-pack" to support fetching from jgitShawn O. Pearce, Dec 23, 2008
  5. 4/5 Fix BaseFetchPackConnection's output of selected capabilitiesShawn O. Pearce, Dec 23, 2008
  6. 5/5 Switch local fetch connection to use our own UploadPackShawn O. Pearce, Dec 23, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.