File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change
1
+ use std:: ffi:: OsStr ;
1
2
use std:: path:: { Path , PathBuf } ;
2
3
3
4
use git_config:: file:: GitConfig ;
@@ -30,13 +31,20 @@ where
30
31
{
31
32
progress. init ( None , progress:: count ( "filesystem items" ) ) ;
32
33
fn is_repository ( path : & Path ) -> Option < git_repository:: Kind > {
33
- if !( path. is_dir ( ) && path. ends_with ( ".git" ) ) {
34
+ // Can be git dir or worktree checkout (file)
35
+ if path. file_name ( ) != Some ( OsStr :: new ( ".git" ) ) {
34
36
return None ;
35
37
}
36
- if path. join ( "HEAD" ) . is_file ( ) && path. join ( "config" ) . is_file ( ) {
37
- git_repository:: path:: is:: git ( path) . ok ( )
38
+
39
+ if path. is_dir ( ) {
40
+ if path. join ( "HEAD" ) . is_file ( ) && path. join ( "config" ) . is_file ( ) {
41
+ git_repository:: path:: is:: git ( path) . ok ( )
42
+ } else {
43
+ None
44
+ }
38
45
} else {
39
- None
46
+ // git files are always worktrees
47
+ Some ( git_repository:: Kind :: WorkTree )
40
48
}
41
49
}
42
50
fn into_workdir ( git_dir : PathBuf ) -> PathBuf {
You can’t perform that action at this time.
0 commit comments