ignore: make sure we have an xdg path before using it

Commit e3ebc35 (config: fix several access(NULL) calls, 2012-07-12) was fixing access(NULL) calls when trying to access $HOME/.config/git/config, but missed the ones when trying to access $HOME/.config/git/ignore. Fix and test this. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Jul 24, 2012 at 14:26 UTC 6283a376c47e7ca3327e563143c1ceda39ae25ac
2 files changed +8 -1
dir.c
+1 -1
@@ -1302,7 +1302,7 @@ void setup_standard_excludes(struct dir_struct *dir)
1302 }
1303 if (!access(path, R_OK))
1304 add_excludes_from_file(dir, path);
1305 - if (!access(excludes_file, R_OK))
1305 + if (excludes_file && !access(excludes_file, R_OK))
1306 add_excludes_from_file(dir, excludes_file);
1307 }
1308
t/t1306-xdg-files.sh
+7
@@ -95,6 +95,13 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' '
95 test_must_fail git add to_be_excluded
96 '
97
98 +test_expect_success 'Checking XDG ignore file when HOME is unset' '
99 + >expected &&
100 + (sane_unset HOME &&
101 + git config --unset core.excludesfile &&
102 + git ls-files --exclude-standard --ignored >actual) &&
103 + test_cmp expected actual
104 +'
105
106 test_expect_success 'Checking attributes in the XDG attributes file' '
107 echo foo >f &&