Skip to content

Commit 8cd97db

Browse files
authored
fix: find_git_root allows any .git (#11525)
Not just directories. `.git` can be a file when it's a git-worktree.
1 parent 6dc1b4a commit 8cd97db

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/config/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn load_config_with_root(root: Option<&Path>) -> eyre::Result<Config> {
3535
pub fn find_git_root(relative_to: &Path) -> io::Result<Option<PathBuf>> {
3636
let root =
3737
if relative_to.is_absolute() { relative_to } else { &dunce::canonicalize(relative_to)? };
38-
Ok(root.ancestors().find(|p| p.join(".git").is_dir()).map(Path::to_path_buf))
38+
Ok(root.ancestors().find(|p| p.join(".git").exists()).map(Path::to_path_buf))
3939
}
4040

4141
/// Returns the root path to set for the project root.

0 commit comments

Comments
 (0)