File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1+ use std:: ffi:: OsStr ;
12use std:: path:: { Path , PathBuf } ;
23
34use git_config:: file:: GitConfig ;
@@ -30,13 +31,20 @@ where
3031{
3132 progress. init ( None , progress:: count ( "filesystem items" ) ) ;
3233 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" ) ) {
3436 return None ;
3537 }
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+ }
3845 } else {
39- None
46+ // git files are always worktrees
47+ Some ( git_repository:: Kind :: WorkTree )
4048 }
4149 }
4250 fn into_workdir ( git_dir : PathBuf ) -> PathBuf {
You can’t perform that action at this time.
0 commit comments