summaryrefslogtreecommitdiff
path: root/t/t1306-xdg-files.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-07-24 11:53:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-07-24 15:59:07 (GMT)
commitf0c1c15c41bdcdaf71c69355ac83789466820879 (patch)
tree261e34e95f83564ce0afcc737e9d9134c642289a /t/t1306-xdg-files.sh
parent5adf84ebb375eeee998edef9a2b5aaa05df677d0 (diff)
downloadgit-f0c1c15c41bdcdaf71c69355ac83789466820879.zip
git-f0c1c15c41bdcdaf71c69355ac83789466820879.tar.gz
git-f0c1c15c41bdcdaf71c69355ac83789466820879.tar.bz2
attr: make sure we have an xdg path before using it
If we don't have a core.attributesfile configured, we fall back to checking XDG config, which is usually $HOME/.config/git/attributes. However, if $HOME is unset, then home_config_paths will return NULL, and we end up calling fopen(NULL). Depending on your system, this may or may not cause the accompanying test to fail (e.g., on Linux and glibc, the address will go straight to open, which will return EFAULT). However, valgrind will reliably notice the error. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1306-xdg-files.sh')
-rwxr-xr-xt/t1306-xdg-files.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh
index 3c75c3f..1569596 100755
--- a/t/t1306-xdg-files.sh
+++ b/t/t1306-xdg-files.sh
@@ -106,6 +106,12 @@ test_expect_success 'Checking attributes in the XDG attributes file' '
test_cmp expected actual
'
+test_expect_success 'Checking XDG attributes when HOME is unset' '
+ >expected &&
+ (sane_unset HOME &&
+ git check-attr -a f >actual) &&
+ test_cmp expected actual
+'
test_expect_success 'Checking attributes in both XDG and local attributes files' '
echo "f -attr_f" >.gitattributes &&