config: write to $XDG_CONFIG_HOME/git/config file when appropriate
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index 2c02b312b77f3363c234bdc66faaeafd5899586d..390367fa6703624e4566006f647b875f96764ba8 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1292,12 +1292,17 @@ int remove_dir_recursively(struct strbuf *path, int flag)
 void setup_standard_excludes(struct dir_struct *dir)
 {
        const char *path;
+       char *xdg_path;
 
        dir->exclude_per_dir = ".gitignore";
        path = git_path("info/exclude");
+       if (!excludes_file) {
+               home_config_paths(NULL, &xdg_path, "ignore");
+               excludes_file = xdg_path;
+       }
        if (!access(path, R_OK))
                add_excludes_from_file(dir, path);
-       if (excludes_file && !access(excludes_file, R_OK))
+       if (!access(excludes_file, R_OK))
                add_excludes_from_file(dir, excludes_file);
 }