@@ -22,6 +22,18 @@ fn from_bare_git_dir() -> crate::Result {
2222 Ok ( ( ) )
2323}
2424
25+ #[ test]
26+ fn from_bare_git_dir_without_config_file ( ) -> crate :: Result {
27+ for name in [ "bare-no-config.git" , "bare-no-config-after-init.git" ] {
28+ let dir = repo_path ( ) ?. join ( name) ;
29+ let ( path, trust) = git_discover:: upwards ( & dir) ?;
30+ assert_eq ! ( path. as_ref( ) , dir, "the bare .git dir is directly returned" ) ;
31+ assert_eq ! ( path. kind( ) , Kind :: Bare ) ;
32+ assert_eq ! ( trust, expected_trust( ) ) ;
33+ }
34+ Ok ( ( ) )
35+ }
36+
2537#[ test]
2638fn from_inside_bare_git_dir ( ) -> crate :: Result {
2739 let git_dir = repo_path ( ) ?. join ( "bare.git" ) ;
@@ -61,6 +73,18 @@ fn from_working_dir() -> crate::Result {
6173 Ok ( ( ) )
6274}
6375
76+ #[ test]
77+ fn from_working_dir_no_config ( ) -> crate :: Result {
78+ for name in [ "worktree-no-config-after-init" , "worktree-no-config" ] {
79+ let dir = repo_path ( ) ?. join ( name) ;
80+ let ( path, trust) = git_discover:: upwards ( & dir) ?;
81+ assert_eq ! ( path. kind( ) , Kind :: WorkTree { linked_git_dir: None } , ) ;
82+ assert_eq ! ( path. as_ref( ) , dir, "a working tree dir yields the git dir" ) ;
83+ assert_eq ! ( trust, expected_trust( ) ) ;
84+ }
85+ Ok ( ( ) )
86+ }
87+
6488#[ test]
6589fn from_nested_dir ( ) -> crate :: Result {
6690 let working_dir = repo_path ( ) ?;
@@ -328,6 +352,6 @@ mod submodules {
328352 }
329353}
330354
331- fn repo_path ( ) -> crate :: Result < PathBuf > {
355+ pub ( crate ) fn repo_path ( ) -> crate :: Result < PathBuf > {
332356 git_testtools:: scripted_fixture_repo_read_only ( "make_basic_repo.sh" )
333357}
0 commit comments