@ -1279,6 +1279,48 @@ public class UploadPackTest {
assertTrue ( client . hasObject ( merge . toObjectId ( ) ) ) ;
assertTrue ( client . hasObject ( merge . toObjectId ( ) ) ) ;
}
}
@Test
public void testV2FetchShallowSince_excludedParentWithMultipleChildren ( ) throws Exception {
PersonIdent person = new PersonIdent ( remote . getRepository ( ) ) ;
RevCommit base = remote . commit ( )
. committer ( new PersonIdent ( person , 1500000000 , 0 ) ) . create ( ) ;
RevCommit child1 = remote . commit ( ) . parent ( base )
. committer ( new PersonIdent ( person , 1510000000 , 0 ) ) . create ( ) ;
RevCommit child2 = remote . commit ( ) . parent ( base )
. committer ( new PersonIdent ( person , 1520000000 , 0 ) ) . create ( ) ;
remote . update ( "branch1" , child1 ) ;
remote . update ( "branch2" , child2 ) ;
ByteArrayInputStream recvStream = uploadPackV2 (
"command=fetch\n" ,
PacketLineIn . DELIM ,
"deepen-since 1510000\n" ,
"want " + child1 . toObjectId ( ) . getName ( ) + "\n" ,
"want " + child2 . toObjectId ( ) . getName ( ) + "\n" ,
"done\n" ,
PacketLineIn . END ) ;
PacketLineIn pckIn = new PacketLineIn ( recvStream ) ;
assertThat ( pckIn . readString ( ) , is ( "shallow-info" ) ) ;
// "base" is excluded, so its children are shallow.
assertThat (
Arrays . asList ( pckIn . readString ( ) , pckIn . readString ( ) ) ,
hasItems (
"shallow " + child1 . toObjectId ( ) . getName ( ) ,
"shallow " + child2 . toObjectId ( ) . getName ( ) ) ) ;
assertThat ( pckIn . readString ( ) , theInstance ( PacketLineIn . DELIM ) ) ;
assertThat ( pckIn . readString ( ) , is ( "packfile" ) ) ;
parsePack ( recvStream ) ;
// Only the children are sent.
assertFalse ( client . hasObject ( base . toObjectId ( ) ) ) ;
assertTrue ( client . hasObject ( child1 . toObjectId ( ) ) ) ;
assertTrue ( client . hasObject ( child2 . toObjectId ( ) ) ) ;
}
@Test
@Test
public void testV2FetchShallowSince_noCommitsSelected ( ) throws Exception {
public void testV2FetchShallowSince_noCommitsSelected ( ) throws Exception {
PersonIdent person = new PersonIdent ( remote . getRepository ( ) ) ;
PersonIdent person = new PersonIdent ( remote . getRepository ( ) ) ;
@ -1405,6 +1447,49 @@ public class UploadPackTest {
assertTrue ( client . hasObject ( four . toObjectId ( ) ) ) ;
assertTrue ( client . hasObject ( four . toObjectId ( ) ) ) ;
}
}
@Test
public void testV2FetchDeepenNot_excludedParentWithMultipleChildren ( ) throws Exception {
PersonIdent person = new PersonIdent ( remote . getRepository ( ) ) ;
RevCommit base = remote . commit ( )
. committer ( new PersonIdent ( person , 1500000000 , 0 ) ) . create ( ) ;
RevCommit child1 = remote . commit ( ) . parent ( base )
. committer ( new PersonIdent ( person , 1510000000 , 0 ) ) . create ( ) ;
RevCommit child2 = remote . commit ( ) . parent ( base )
. committer ( new PersonIdent ( person , 1520000000 , 0 ) ) . create ( ) ;
remote . update ( "base" , base ) ;
remote . update ( "branch1" , child1 ) ;
remote . update ( "branch2" , child2 ) ;
ByteArrayInputStream recvStream = uploadPackV2 (
"command=fetch\n" ,
PacketLineIn . DELIM ,
"deepen-not base\n" ,
"want " + child1 . toObjectId ( ) . getName ( ) + "\n" ,
"want " + child2 . toObjectId ( ) . getName ( ) + "\n" ,
"done\n" ,
PacketLineIn . END ) ;
PacketLineIn pckIn = new PacketLineIn ( recvStream ) ;
assertThat ( pckIn . readString ( ) , is ( "shallow-info" ) ) ;
// "base" is excluded, so its children are shallow.
assertThat (
Arrays . asList ( pckIn . readString ( ) , pckIn . readString ( ) ) ,
hasItems (
"shallow " + child1 . toObjectId ( ) . getName ( ) ,
"shallow " + child2 . toObjectId ( ) . getName ( ) ) ) ;
assertThat ( pckIn . readString ( ) , theInstance ( PacketLineIn . DELIM ) ) ;
assertThat ( pckIn . readString ( ) , is ( "packfile" ) ) ;
parsePack ( recvStream ) ;
// Only the children are sent.
assertFalse ( client . hasObject ( base . toObjectId ( ) ) ) ;
assertTrue ( client . hasObject ( child1 . toObjectId ( ) ) ) ;
assertTrue ( client . hasObject ( child2 . toObjectId ( ) ) ) ;
}
@Test
@Test
public void testV2FetchUnrecognizedArgument ( ) throws Exception {
public void testV2FetchUnrecognizedArgument ( ) throws Exception {
thrown . expect ( PackProtocolException . class ) ;
thrown . expect ( PackProtocolException . class ) ;