1
- use std:: {
2
- ffi:: OsStr ,
3
- path:: { Path , PathBuf } ,
4
- } ;
1
+ use std:: { ffi:: OsStr , path:: Path } ;
5
2
6
3
/// Returns true if the given `git_dir` seems to be a bare repository.
7
4
///
8
- /// Please note that repositories without any file in their work tree will also appear bare .
5
+ /// Please note that repositories without an index generally _look_ bare, even though they might also be uninitialized .
9
6
pub fn bare ( git_dir_candidate : impl AsRef < Path > ) -> bool {
10
7
let git_dir = git_dir_candidate. as_ref ( ) ;
11
8
!( git_dir. join ( "index" ) . exists ( ) || ( git_dir. file_name ( ) == Some ( OsStr :: new ( ".git" ) ) && git_dir. is_file ( ) ) )
12
9
}
13
10
14
- /// What constitutes a valid git repository, and what's yet to be implemented, returning the guessed repository kind
11
+ /// What constitutes a valid git repository, returning the guessed repository kind
15
12
/// purely based on the presence of files. Note that the git-config ultimately decides what's bare.
16
13
///
17
14
/// * [ ] git files
18
15
/// * [x] a valid head
19
16
/// * [ ] git common directory
20
- /// * [ ] respect GIT_COMMON_DIR
21
17
/// * [x] an objects directory
22
- /// * [x] respect GIT_OBJECT_DIRECTORY
23
18
/// * [x] a refs directory
19
+ // TODO: allow configuring common dirs at least
24
20
pub fn git ( git_dir : impl AsRef < Path > ) -> Result < crate :: repository:: Kind , crate :: is_git:: Error > {
25
21
let dot_git = git_dir. as_ref ( ) ;
26
22
@@ -43,9 +39,7 @@ pub fn git(git_dir: impl AsRef<Path>) -> Result<crate::repository::Kind, crate::
43
39
}
44
40
45
41
{
46
- let objects_path = std:: env:: var ( "GIT_OBJECT_DIRECTORY" )
47
- . map ( PathBuf :: from)
48
- . unwrap_or_else ( |_| dot_git. join ( "objects" ) ) ;
42
+ let objects_path = dot_git. join ( "objects" ) ;
49
43
if !objects_path. is_dir ( ) {
50
44
return Err ( crate :: is_git:: Error :: MissingObjectsDirectory { missing : objects_path } ) ;
51
45
}
0 commit comments