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

[JGIT PATCH] Fix push to empty repository

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 16, 2008, 05:38 UTC
Message-ID
<1221543484-51295-1-git-send-email-spearce@spearce.org>

If the remote repository has no commits we received an exception about "capabilities^{} coming before capabilities". This happens because we didn't correctly ignore the dummy capability ref line.

http://code.google.com/p/egit/issues/detail?id=34
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../spearce/jgit/transport/BasePackConnection.java |   12 ++++++------
 1 files changed, 6 insertions(+), 6 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 184a5fd..2d145a6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/BasePackConnection.java
@@ -147,18 +147,18 @@ for (String c : line.substring(nul + 1).split(" "))
 						remoteCapablities.add(c);
 					line = line.substring(0, nul);
 				}
-
-				if (line.equals("capabilities^{}")) {
-					// special line from git-receive-pack to show
-					// capabilities when there are no refs to advertise
-					continue;
-				}
 			}
 
 			if (line.length() == 0)
 				break;
 
 			String name = line.substring(41, line.length());
+			if (avail.isEmpty() && name.equals("capabilities^{}")) {
+				// special line from git-receive-pack to show
+				// capabilities when there are no refs to advertise
+				continue;
+			}
+
 			final ObjectId id = ObjectId.fromString(line.substring(0, 40));
 			if (name.endsWith("^{}")) {
 				name = name.substring(0, name.length() - 3);
-- 
1.6.0.1.337.g5c7d67
Message 1 of 1 in “Fix push to empty repository”
  1. Fix push to empty repositoryShawn O. Pearce, Sep 16, 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.