@ -140,7 +140,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
@Test
public void testResetHard ( ) throws IOException , NoFilepatternException ,
GitAPIException {
Git git = new Git ( db ) ;
try ( Git git = new Git ( db ) ) {
writeTrashFile ( "f" , "f()" ) ;
writeTrashFile ( "D/g" , "g()" ) ;
git . add ( ) . addFilepattern ( "." ) . call ( ) ;
@ -187,6 +187,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
assertWorkDir ( mkmap ( "f" , "f()\nmaster" , "D/g" , "g()\ng2()" , "E/h" ,
"h()" , "untracked" , "untracked" ) ) ;
}
}
/ * *
* Reset hard from unclean condition .
@ -200,7 +201,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
@Test
public void testResetHardFromIndexEntryWithoutFileToTreeWithoutFile ( )
throws Exception {
Git git = new Git ( db ) ;
try ( Git git = new Git ( db ) ) {
writeTrashFile ( "x" , "x" ) ;
git . add ( ) . addFilepattern ( "x" ) . call ( ) ;
RevCommit id1 = git . commit ( ) . setMessage ( "c1" ) . call ( ) ;
@ -216,6 +217,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
git . reset ( ) . setMode ( ResetType . HARD ) . setRef ( id1 . getName ( ) ) . call ( ) ;
assertIndex ( mkmap ( "x" , "x" ) ) ;
}
}
/ * *
* Test first checkout in a repo
@ -224,8 +226,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
* /
@Test
public void testInitialCheckout ( ) throws Exception {
Git git = new Git ( db ) ;
try ( Git git = new Git ( db ) ) {
TestRepository < Repository > db_t = new TestRepository < Repository > ( db ) ;
BranchBuilder master = db_t . branch ( "master" ) ;
master . commit ( ) . add ( "f" , "1" ) . message ( "m0" ) . create ( ) ;
@ -233,6 +234,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
git . checkout ( ) . setName ( "master" ) . call ( ) ;
assertTrue ( new File ( db . getWorkTree ( ) , "f" ) . exists ( ) ) ;
}
}
private DirCacheCheckout resetHard ( RevCommit commit )
throws NoWorkTreeException ,
@ -1612,7 +1614,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
public void assertWorkDir ( Map < String , String > i )
throws CorruptObjectException ,
IOException {
TreeWalk walk = new TreeWalk ( db ) ;
try ( TreeWalk walk = new TreeWalk ( db ) ) {
walk . setRecursive ( false ) ;
walk . addTree ( new FileTreeIterator ( db ) ) ;
String expectedValue ;
@ -1655,3 +1657,4 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
assertEquals ( "WorkDir has not the right size." , i . size ( ) , nrFiles ) ;
}
}
}