]> source.dussan.org Git - jgit.git/commitdiff
Send only 1 flush pkt at the end of v2 fetch 80/126580/1
authorJonathan Tan <jonathantanmy@google.com>
Tue, 24 Jul 2018 22:35:16 +0000 (15:35 -0700)
committerJonathan Tan <jonathantanmy@google.com>
Tue, 24 Jul 2018 22:39:32 +0000 (15:39 -0700)
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 <jonathantanmy@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 2a3e1ca56dd7f449876dbae762dc368ec694fd87..9f49073eaea0f1e6bb802330062b0405f976d97f 100644 (file)
@@ -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();
        }
 
index 7de0506bb3d6d44749b6388e6abb26f93f6a6f1e..aedc7a6db293533d770443666e0a9d01091e694b 100644 (file)
@@ -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();
        }
 
        /*