@ -46,6 +46,7 @@ package org.eclipse.jgit.internal.storage.file;
import static org.eclipse.jgit.lib.Constants.HEAD ;
import static org.eclipse.jgit.lib.Constants.R_HEADS ;
import static org.eclipse.jgit.lib.Constants.R_TAGS ;
import static org.eclipse.jgit.lib.ObjectId.zeroId ;
import static org.eclipse.jgit.lib.Ref.Storage.LOOSE ;
import static org.eclipse.jgit.lib.Ref.Storage.NEW ;
import static org.junit.Assert.assertEquals ;
@ -83,7 +84,6 @@ import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTag ;
import org.eclipse.jgit.revwalk.RevWalk ;
import org.eclipse.jgit.transport.ReceiveCommand ;
import org.eclipse.jgit.transport.ReceiveCommand.Type ;
import org.junit.Before ;
import org.junit.Test ;
@ -1297,9 +1297,9 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
writeLooseRef ( "refs/heads/master" , A ) ;
writeLooseRef ( "refs/heads/masters" , B ) ;
List < ReceiveCommand > commands = Arrays . asList (
new Command( A , B , "refs/heads/master" ,
new Receive Command( A , B , "refs/heads/master" ,
ReceiveCommand . Type . UPDATE ) ,
new Command( B , A , "refs/heads/masters" ,
new Receive Command( B , A , "refs/heads/masters" ,
ReceiveCommand . Type . UPDATE_NONFASTFORWARD ) ) ;
BatchRefUpdate batchUpdate = refdir . newBatchUpdate ( ) ;
batchUpdate . addCommand ( commands ) ;
@ -1319,9 +1319,9 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
writeLooseRef ( "refs/heads/master" , A ) ;
writeLooseRef ( "refs/heads/masters" , B ) ;
List < ReceiveCommand > commands = Arrays . asList (
new Command( A , B , "refs/heads/master" ,
new Receive Command( A , B , "refs/heads/master" ,
ReceiveCommand . Type . UPDATE ) ,
new Command( B , A , "refs/heads/masters" ,
new Receive Command( B , A , "refs/heads/masters" ,
ReceiveCommand . Type . UPDATE_NONFASTFORWARD ) ) ;
BatchRefUpdate batchUpdate = refdir . newBatchUpdate ( ) ;
batchUpdate . setAllowNonFastForwards ( true ) ;
@ -1341,7 +1341,7 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
throws IOException {
writeLooseRef ( "refs/heads/master" , B ) ;
List < ReceiveCommand > commands = Arrays . asList (
new Command( B , A , "refs/heads/master" ,
new Receive Command( B , A , "refs/heads/master" ,
ReceiveCommand . Type . UPDATE_NONFASTFORWARD ) ) ;
BatchRefUpdate batchUpdate = refdir . newBatchUpdate ( ) ;
batchUpdate . setAllowNonFastForwards ( true ) ;
@ -1362,11 +1362,12 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
writeLooseRef ( "refs/heads/master" , A ) ;
writeLooseRef ( "refs/heads/masters" , B ) ;
List < ReceiveCommand > commands = Arrays . asList (
new Command( A , B , "refs/heads/master" ,
new Receive Command( A , B , "refs/heads/master" ,
ReceiveCommand . Type . UPDATE ) ,
newCommand ( null , A , "refs/heads/master/x" ,
new ReceiveCommand ( zeroId ( ) , A , "refs/heads/master/x" ,
ReceiveCommand . Type . CREATE ) ,
newCommand ( null , A , "refs/heads" , ReceiveCommand . Type . CREATE ) ) ;
new ReceiveCommand ( zeroId ( ) , A , "refs/heads" ,
ReceiveCommand . Type . CREATE ) ) ;
BatchRefUpdate batchUpdate = refdir . newBatchUpdate ( ) ;
batchUpdate . setAllowNonFastForwards ( true ) ;
batchUpdate . addCommand ( commands ) ;
@ -1389,11 +1390,11 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
writeLooseRef ( "refs/heads/master" , A ) ;
writeLooseRef ( "refs/heads/masters" , B ) ;
List < ReceiveCommand > commands = Arrays . asList (
new Command( A , B , "refs/heads/master" ,
new Receive Command( A , B , "refs/heads/master" ,
ReceiveCommand . Type . UPDATE ) ,
newCommand ( null , A , "refs/heads/masters/x" ,
new ReceiveCommand ( zeroId ( ) , A , "refs/heads/masters/x" ,
ReceiveCommand . Type . CREATE ) ,
new Command( B , null , "refs/heads/masters" ,
new Receive Command( B , zeroId ( ) , "refs/heads/masters" ,
ReceiveCommand . Type . DELETE ) ) ;
BatchRefUpdate batchUpdate = refdir . newBatchUpdate ( ) ;
batchUpdate . setAllowNonFastForwards ( true ) ;
@ -1408,12 +1409,6 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
assertEquals ( A . getId ( ) , refs . get ( "refs/heads/masters/x" ) . getObjectId ( ) ) ;
}
private static ReceiveCommand newCommand ( RevCommit a , RevCommit b ,
String string , Type update ) {
return new ReceiveCommand ( a ! = null ? a . getId ( ) : null ,
b ! = null ? b . getId ( ) : null , string , update ) ;
}
private void writeLooseRef ( String name , AnyObjectId id ) throws IOException {
writeLooseRef ( name , id . name ( ) + "\n" ) ;
}