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

[JGIT PATCH 1/5] Don't dispose of RevFlag used to advertise objects in ReceivePack

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 29, 2009, 15:50 UTC
Message-ID
<1248882627-7285-2-git-send-email-spearce@spearce.org>
In-Reply-To
<1248882627-7285-1-git-send-email-spearce@spearce.org>

Back in 3ae30ae64d56113a71a07a3ff12d0af71cf538e2 I refactored how the ReceivePack and UploadPack programs advertise the set of refs that the server-side currently has. As part of this change ReceivePack allocated a new RevFlag and marked it on all objects it advertised to the client, because the common code with UploadPack requires the RevFlag to mark objects. It also uses this RevFlag to avoid sending ".have" lines for objects we have already described.

Disposing of the RevFlag however is problematic for any application that uses the ReceivePack's RevWalk instance within a PreReceiveHook or a PostReceiveHook implementation. By disposing of the RevFlag, the flag bit was not actually unset from the advertised objects, it was only marked as being eligible for reallocation in another RevFlag. If the flag bit was reallocated, any advertised objects would automatically have the bit set, which can confuse the new user of the bit.

RevWalk's isMergedInto() really got confused, as it allocates a temporary RevFlag for each input RevCommit in order to compute the merge base.

The simplest fix is to just never dispose of this RevFlag once it has been allocated. We could dispose of it and also unset it from all objects we advertised, but that would require us to keep track of the full advertised set, a potentially expensive thing to do given that most callers will never need to allocate a RevFlag, let alone care about the 1 bit leaked by the protocol.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/transport/ReceivePack.java    |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
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 ca4a7ec..eb21254 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
@@ -547,7 +547,6 @@ private void sendAdvertisedRefs() throws IOException {
 		if (adv.isEmpty())
 			adv.advertiseId(ObjectId.zeroId(), "capabilities^{}");
 		pckOut.end();
-		walk.disposeFlag(advertised);
 	}
 
 	private void recvCommands() throws IOException {
-- 
1.6.4.rc3.201.gd9d59
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 2 of 6 in “Some minor bug fixes”
  1. 0/5 Some minor bug fixesShawn O. Pearce, Jul 29, 2009
  2. 1/5 Don't dispose of RevFlag used to advertise objects in ReceivePackShawn O. Pearce, Jul 29, 2009
  3. 2/5 Allow RemoteConfig.getAllRemoteConfigs on any Config objectShawn O. Pearce, Jul 29, 2009
  4. 3/5 Add ConfigInvalidException constructor to take ThrowableShawn O. Pearce, Jul 29, 2009
  5. 4/5 Add no fallback constructor to FileBasedConfigShawn O. Pearce, Jul 29, 2009
  6. 5/5 Include the file path when FileBasedConfig.load throws an exceptionShawn O. Pearce, Jul 29, 2009

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.