@ -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 ) {