Skip to content

Commit 3f28e20

Browse files
committed
feat: ein find with support for worktree checkouts
1 parent 70109be commit 3f28e20

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

gitoxide-core/src/organize.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::ffi::OsStr;
12
use std::path::{Path, PathBuf};
23

34
use 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 {

0 commit comments

Comments
 (0)