Skip to content

Commit 70d7812

Browse files
authored
properly handle detachted git worktrees (helix-editor#5097)
1 parent 0e8ea13 commit 70d7812

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

helix-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn find_root(root: Option<&str>, root_markers: &[String]) -> std::path::Path
6969
top_marker = Some(ancestor);
7070
}
7171

72-
if ancestor.join(".git").is_dir() {
72+
if ancestor.join(".git").exists() {
7373
// Top marker is repo root if not root marker was detected yet
7474
if top_marker.is_none() {
7575
top_marker = Some(ancestor);

helix-loader/src/grammar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ fn fetch_grammar(grammar: GrammarConfiguration) -> Result<FetchStatus> {
263263
))?;
264264

265265
// create the grammar dir contains a git directory
266-
if !grammar_dir.join(".git").is_dir() {
266+
if !grammar_dir.join(".git").exists() {
267267
git(&grammar_dir, ["init"])?;
268268
}
269269

helix-loader/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn find_local_config_dirs() -> Vec<PathBuf> {
9797
let mut directories = Vec::new();
9898

9999
for ancestor in current_dir.ancestors() {
100-
if ancestor.join(".git").is_dir() {
100+
if ancestor.join(".git").exists() {
101101
directories.push(ancestor.to_path_buf());
102102
// Don't go higher than repo if we're in one
103103
break;

helix-term/src/ui/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
207207

208208
// Cap the number of files if we aren't in a git project, preventing
209209
// hangs when using the picker in your home directory
210-
let files: Vec<_> = if root.join(".git").is_dir() {
210+
let files: Vec<_> = if root.join(".git").exists() {
211211
files.collect()
212212
} else {
213213
// const MAX: usize = 8192;

0 commit comments

Comments
 (0)