From: Jonathan Tan Date: Tue, 24 Jul 2018 22:35:16 +0000 (-0700) Subject: Send only 1 flush pkt at the end of v2 fetch X-Git-Tag: v5.1.0.201808281540-m3~49^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7e7b00f1a5d14ceca62fd18c6e11456fc9eddd21;p=jgit.git Send only 1 flush pkt at the end of v2 fetch When processing a fetch using protocol v2, UploadPack#fetchV2 sends an extraneous flush pkt when also sending a packfile (#sendPack sending its own flush pkt). Update that method to only send the flush pkt if the packfile is not being sent. Change-Id: I7117a264bccd2d7f3a048645fcb8425a9d78d526 Signed-off-by: Jonathan Tan --- diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index 2a3e1ca56d..9f49073eae 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java @@ -658,6 +658,10 @@ public class UploadPackTest { new StringWriter(), NullOutputStream.INSTANCE); PackParser pp = client.newObjectInserter().newPackParser(sb); pp.parse(NullProgressMonitor.INSTANCE); + + // Ensure that there is nothing left in the stream. + assertThat(recvStream.read(), is(-1)); + return pp.getReceivedPackStatistics(); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 7de0506bb3..aedc7a6db2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -1083,8 +1083,12 @@ public class UploadPack { ? db.getRefDatabase().getRefsByPrefix(R_TAGS) : null, unshallowCommits); + // sendPack invokes pckOut.end() for us, so we do not + // need to invoke it here. + } else { + // Invoke pckOut.end() by ourselves. + pckOut.end(); } - pckOut.end(); } /*