@ -73,13 +73,14 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
public void testIsBare_CreateRepositoryFromArbitraryGitDir ( )
public void testIsBare_CreateRepositoryFromArbitraryGitDir ( )
throws Exception {
throws Exception {
File gitDir = getFile ( "workdir" ) ;
File gitDir = getFile ( "workdir" ) ;
assertTrue ( new FileRepository ( gitDir ) . isBare ( ) ) ;
Repository repo = new FileRepositoryBuilder ( ) . setGitDir ( gitDir ) . build ( ) ;
assertTrue ( repo . isBare ( ) ) ;
}
}
@Test
@Test
public void testNotBare_CreateRepositoryFromDotGitGitDir ( ) throws Exception {
public void testNotBare_CreateRepositoryFromDotGitGitDir ( ) throws Exception {
File gitDir = getFile ( "workdir" , Constants . DOT_GIT ) ;
File gitDir = getFile ( "workdir" , Constants . DOT_GIT ) ;
Repository repo = new FileRepository ( gitDir ) ;
Repository repo = new FileRepositoryBuilder ( ) . setGitDir ( gitDir ) . build ( ) ;
assertFalse ( repo . isBare ( ) ) ;
assertFalse ( repo . isBare ( ) ) ;
assertWorkdirPath ( repo , "workdir" ) ;
assertWorkdirPath ( repo , "workdir" ) ;
assertGitdirPath ( repo , "workdir" , Constants . DOT_GIT ) ;
assertGitdirPath ( repo , "workdir" , Constants . DOT_GIT ) ;
@ -89,7 +90,7 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
public void testWorkdirIsParentDir_CreateRepositoryFromDotGitGitDir ( )
public void testWorkdirIsParentDir_CreateRepositoryFromDotGitGitDir ( )
throws Exception {
throws Exception {
File gitDir = getFile ( "workdir" , Constants . DOT_GIT ) ;
File gitDir = getFile ( "workdir" , Constants . DOT_GIT ) ;
Repository repo = new FileRepository ( gitDir ) ;
Repository repo = new FileRepositoryBuilder ( ) . setGitDir ( gitDir ) . build ( ) ;
String workdir = repo . getWorkTree ( ) . getName ( ) ;
String workdir = repo . getWorkTree ( ) . getName ( ) ;
assertEquals ( workdir , "workdir" ) ;
assertEquals ( workdir , "workdir" ) ;
}
}
@ -157,8 +158,8 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
@Test
@Test
public void testExceptionThrown_BareRepoGetWorkDir ( ) throws Exception {
public void testExceptionThrown_BareRepoGetWorkDir ( ) throws Exception {
File gitDir = getFile ( "workdir" ) ;
File gitDir = getFile ( "workdir" ) ;
try {
try ( Repository repo = new FileRepository ( gitDir ) ) {
new FileRepository ( gitDir ) . getWorkTree ( ) ;
repo . getWorkTree ( ) ;
fail ( "Expected NoWorkTreeException missing" ) ;
fail ( "Expected NoWorkTreeException missing" ) ;
} catch ( NoWorkTreeException e ) {
} catch ( NoWorkTreeException e ) {
// expected
// expected
@ -168,8 +169,8 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
@Test
@Test
public void testExceptionThrown_BareRepoGetIndex ( ) throws Exception {
public void testExceptionThrown_BareRepoGetIndex ( ) throws Exception {
File gitDir = getFile ( "workdir" ) ;
File gitDir = getFile ( "workdir" ) ;
try {
try ( Repository repo = new FileRepository ( gitDir ) ) {
new FileRepository ( gitDir ) . readDirCache ( ) ;
repo . readDirCache ( ) ;
fail ( "Expected NoWorkTreeException missing" ) ;
fail ( "Expected NoWorkTreeException missing" ) ;
} catch ( NoWorkTreeException e ) {
} catch ( NoWorkTreeException e ) {
// expected
// expected
@ -179,8 +180,8 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
@Test
@Test
public void testExceptionThrown_BareRepoGetIndexFile ( ) throws Exception {
public void testExceptionThrown_BareRepoGetIndexFile ( ) throws Exception {
File gitDir = getFile ( "workdir" ) ;
File gitDir = getFile ( "workdir" ) ;
try {
try ( Repository repo = new FileRepository ( gitDir ) ) {
new FileRepository ( gitDir ) . getIndexFile ( ) ;
repo . getIndexFile ( ) ;
fail ( "Expected NoWorkTreeException missing" ) ;
fail ( "Expected NoWorkTreeException missing" ) ;
} catch ( NoWorkTreeException e ) {
} catch ( NoWorkTreeException e ) {
// expected
// expected