diff --git a/ignore/src/gitignore.rs b/ignore/src/gitignore.rs index 5523fa6d..6a0bc969 100644 --- a/ignore/src/gitignore.rs +++ b/ignore/src/gitignore.rs @@ -453,9 +453,9 @@ fn gitconfig_contents() -> Option> { /// Specifically, this respects XDG_CONFIG_HOME. fn excludes_file_default() -> Option { env::var_os("XDG_CONFIG_HOME") - .and_then(|x| if x.is_empty() { None } else { Some(x) }) - .or_else(|| env::var_os("HOME")) - .map(|x| PathBuf::from(x).join("git/ignore")) + .and_then(|x| if x.is_empty() { None } else { Some(PathBuf::from(x)) }) + .or_else(|| env::home_dir()) + .map(|x| x.join("git/ignore")) } /// Extract git's `core.excludesfile` config setting from the raw file contents