Skip to content

Commit

Permalink
ignore: make sure we have an xdg path before using it
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matthieu Moy authored and Junio C Hamano committed Jul 24, 2012
1 parent f0c1c15 commit 6283a37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ void setup_standard_excludes(struct dir_struct *dir)
}
if (!access(path, R_OK))
add_excludes_from_file(dir, path);
if (!access(excludes_file, R_OK))
if (excludes_file && !access(excludes_file, R_OK))
add_excludes_from_file(dir, excludes_file);
}

Expand Down
7 changes: 7 additions & 0 deletions t/t1306-xdg-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' '
test_must_fail git add to_be_excluded
'

test_expect_success 'Checking XDG ignore file when HOME is unset' '
>expected &&
(sane_unset HOME &&
git config --unset core.excludesfile &&
git ls-files --exclude-standard --ignored >actual) &&
test_cmp expected actual
'

test_expect_success 'Checking attributes in the XDG attributes file' '
echo foo >f &&
Expand Down

0 comments on commit 6283a37

Please sign in to comment.