properly handle detachted git worktrees (#5097)

This commit is contained in:
Pascal Kuthe 2022-12-11 11:20:34 +01:00 committed by GitHub
parent 0e8ea13696
commit 70d78123b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -69,7 +69,7 @@ pub fn find_root(root: Option<&str>, root_markers: &[String]) -> std::path::Path
top_marker = Some(ancestor);
}
if ancestor.join(".git").is_dir() {
if ancestor.join(".git").exists() {
// Top marker is repo root if not root marker was detected yet
if top_marker.is_none() {
top_marker = Some(ancestor);

View file

@ -263,7 +263,7 @@ fn fetch_grammar(grammar: GrammarConfiguration) -> Result<FetchStatus> {
))?;
// create the grammar dir contains a git directory
if !grammar_dir.join(".git").is_dir() {
if !grammar_dir.join(".git").exists() {
git(&grammar_dir, ["init"])?;
}

View file

@ -97,7 +97,7 @@ pub fn find_local_config_dirs() -> Vec<PathBuf> {
let mut directories = Vec::new();
for ancestor in current_dir.ancestors() {
if ancestor.join(".git").is_dir() {
if ancestor.join(".git").exists() {
directories.push(ancestor.to_path_buf());
// Don't go higher than repo if we're in one
break;

View file

@ -207,7 +207,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
// Cap the number of files if we aren't in a git project, preventing
// hangs when using the picker in your home directory
let files: Vec<_> = if root.join(".git").is_dir() {
let files: Vec<_> = if root.join(".git").exists() {
files.collect()
} else {
// const MAX: usize = 8192;