summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-07-24 12:27:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-07-24 15:59:07 (GMT)
commit22ae029a1e0631570a2db5d030e5755f9be96eee (patch)
tree77530ef5277b26bc693a9c3b91dfa80b712759a4
parent6283a376c47e7ca3327e563143c1ceda39ae25ac (diff)
downloadgit-22ae029a1e0631570a2db5d030e5755f9be96eee.zip
git-22ae029a1e0631570a2db5d030e5755f9be96eee.tar.gz
git-22ae029a1e0631570a2db5d030e5755f9be96eee.tar.bz2
t1306: check that XDG_CONFIG_HOME works
This should override $HOME/.config, but we never actually tested it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t1306-xdg-files.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh
index 94bb696..8b14ab1 100755
--- a/t/t1306-xdg-files.sh
+++ b/t/t1306-xdg-files.sh
@@ -38,6 +38,13 @@ test_expect_success 'read with --get: xdg file exists and ~/.gitconfig doesn'\''
test_cmp expected actual
'
+test_expect_success '"$XDG_CONFIG_HOME overrides $HOME/.config/git' '
+ mkdir -p "$HOME"/xdg/git &&
+ echo "[user]name = in_xdg" >"$HOME"/xdg/git/config &&
+ echo in_xdg >expected &&
+ XDG_CONFIG_HOME="$HOME"/xdg git config --get-all user.name >actual &&
+ test_cmp expected actual
+'
test_expect_success 'read with --get: xdg file exists and ~/.gitconfig exists' '
>.gitconfig &&
@@ -80,6 +87,17 @@ test_expect_success 'Exclusion of a file in the XDG ignore file' '
test_must_fail git add to_be_excluded
'
+test_expect_success '$XDG_CONFIG_HOME overrides $HOME/.config/git/ignore' '
+ mkdir -p "$HOME"/xdg/git &&
+ echo content >excluded_by_xdg_only &&
+ echo excluded_by_xdg_only >"$HOME"/xdg/git/ignore &&
+ test_when_finished "git read-tree --empty" &&
+ (XDG_CONFIG_HOME="$HOME/xdg" &&
+ export XDG_CONFIG_HOME &&
+ git add to_be_excluded &&
+ test_must_fail git add excluded_by_xdg_only
+ )
+'
test_expect_success 'Exclusion in both XDG and local ignore files' '
echo to_be_excluded >.gitignore &&
@@ -120,6 +138,14 @@ test_expect_success 'Checking XDG attributes when HOME is unset' '
test_cmp expected actual
'
+test_expect_success '$XDG_CONFIG_HOME overrides $HOME/.config/git/attributes' '
+ mkdir -p "$HOME"/xdg/git &&
+ echo "f attr_f=xdg" >"$HOME"/xdg/git/attributes &&
+ echo "f: attr_f: xdg" >expected &&
+ XDG_CONFIG_HOME="$HOME/xdg" 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 &&
echo "f: attr_f: unset" >expected &&