Add handling of git's core.excludesFile (#33592)

Taking over from #28314.

Part of https://github.com/zed-industries/zed/issues/4824

Co-authored-by: Paul Nameless <reacsdas@gmail.com>

Release Notes:

- Zed now respects git's `core.excludesFile` (~/.config/git/ignore) in
addition to .gitignore.

---------

Co-authored-by: Paul Nameless <reacsdas@gmail.com>
This commit is contained in:
Cole Miller
2025-09-11 21:00:03 -04:00
committed by GitHub
co-authored by Paul Nameless
parent b60e705782
commit 45ee1327a4
15 changed files with 454 additions and 136 deletions
+22 -2
View File
@@ -12,10 +12,30 @@ use std::{
sync::LazyLock,
};
static HOME_DIR: OnceLock<PathBuf> = OnceLock::new();
/// Returns the path to the user's home directory.
pub fn home_dir() -> &'static PathBuf {
static HOME_DIR: OnceLock<PathBuf> = OnceLock::new();
HOME_DIR.get_or_init(|| dirs::home_dir().expect("failed to determine home directory"))
HOME_DIR.get_or_init(|| {
if cfg!(any(test, feature = "test-support")) {
if cfg!(target_os = "macos") {
PathBuf::from("/Users/zed")
} else if cfg!(target_os = "windows") {
PathBuf::from("C:\\Users\\zed")
} else {
PathBuf::from("/home/zed")
}
} else {
dirs::home_dir().expect("failed to determine home directory")
}
})
}
#[cfg(any(test, feature = "test-support"))]
pub fn set_home_dir(path: PathBuf) {
HOME_DIR
.set(path)
.expect("set_home_dir called after home_dir was already accessed");
}
pub trait PathExt {