Skip to content

Commit 6283a37

Browse files
moygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f0c1c15 commit 6283a37

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ void setup_standard_excludes(struct dir_struct *dir)
13021302
}
13031303
if (!access(path, R_OK))
13041304
add_excludes_from_file(dir, path);
1305-
if (!access(excludes_file, R_OK))
1305+
if (excludes_file && !access(excludes_file, R_OK))
13061306
add_excludes_from_file(dir, excludes_file);
13071307
}
13081308

t/t1306-xdg-files.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' '
9595
test_must_fail git add to_be_excluded
9696
'
9797

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+
'
98105

99106
test_expect_success 'Checking attributes in the XDG attributes file' '
100107
echo foo >f &&

0 commit comments

Comments
 (0)