summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-03-01 15:45:19 -0800
committerJonathan Nieder <jrn@google.com>2018-04-23 10:26:51 -0700
commitdf1f3c0f3c730a0d0edc13ff1f54d5aad476c9b5 (patch)
tree55e5592e19e6de0b44f1d82784df7699b46c7a13 /org.eclipse.jgit.test
parenta5dee1c125737cce7a83a052b4f9d84eb48d62d1 (diff)
downloadjgit-df1f3c0f3c730a0d0edc13ff1f54d5aad476c9b5.tar.gz
jgit-df1f3c0f3c730a0d0edc13ff1f54d5aad476c9b5.zip
Teach UploadPack "no-progress" in "fetch"
Add support for the "no-progress" parameter in the "fetch" command in the fetch-pack/upload-pack protocol v2. Change-Id: I6a6d6b1534f44845254b81d0e1f5c4ba2ac3d10b Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java42
1 files changed, 42 insertions, 0 deletions
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 b83cf1fb71..9a50fb7cea 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
@@ -21,9 +21,11 @@ import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.NullProgressMonitor;
+import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Sets;
+import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.revwalk.RevBlob;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTree;
@@ -535,6 +537,13 @@ public class UploadPackTest {
SideBandInputStream sb = new SideBandInputStream(
recvStream, NullProgressMonitor.INSTANCE,
new StringWriter(), NullOutputStream.INSTANCE);
+ parsePack(recvStream, NullProgressMonitor.INSTANCE);
+ }
+
+ private void parsePack(ByteArrayInputStream recvStream, ProgressMonitor pm)
+ throws Exception {
+ SideBandInputStream sb = new SideBandInputStream(
+ recvStream, pm, new StringWriter(), NullOutputStream.INSTANCE);
client.newObjectInserter().newPackParser(sb).parse(NullProgressMonitor.INSTANCE);
}
@@ -781,6 +790,39 @@ public class UploadPackTest {
parsePack(recvStream);
}
+ @Test
+ public void testV2FetchNoProgress() throws Exception {
+ RevCommit commit = remote.commit().message("x").create();
+ remote.update("branch1", commit);
+
+ // Without no-progress, progress is reported.
+ StringWriter sw = new StringWriter();
+ ByteArrayInputStream recvStream = uploadPackV2(
+ "command=fetch\n",
+ PacketLineIn.DELIM,
+ "want " + commit.toObjectId().getName() + "\n",
+ "done\n",
+ PacketLineIn.END);
+ PacketLineIn pckIn = new PacketLineIn(recvStream);
+ assertThat(pckIn.readString(), is("packfile"));
+ parsePack(recvStream, new TextProgressMonitor(sw));
+ assertFalse(sw.toString().isEmpty());
+
+ // With no-progress, progress is not reported.
+ sw = new StringWriter();
+ recvStream = uploadPackV2(
+ "command=fetch\n",
+ PacketLineIn.DELIM,
+ "want " + commit.toObjectId().getName() + "\n",
+ "no-progress\n",
+ "done\n",
+ PacketLineIn.END);
+ pckIn = new PacketLineIn(recvStream);
+ assertThat(pckIn.readString(), is("packfile"));
+ parsePack(recvStream, new TextProgressMonitor(sw));
+ assertTrue(sw.toString().isEmpty());
+ }
+
private static class RejectAllRefFilter implements RefFilter {
@Override
public Map<String, Ref> filter(Map<String, Ref> refs) {