Thread (6 messages) 6 messages, 1 author, 2016-06-15
DORMANTno replies

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

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:47:07
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 .../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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help