3 # Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
4 # Thomas Nguy, Khoi Nguyen
8 test_description
='Compatibility with $XDG_CONFIG_HOME/git/ files'
12 test_expect_success
'read config: xdg file exists and ~/.gitconfig doesn'\''t' '
13 mkdir -p .config/git &&
14 echo "[alias]" >.config/git/config &&
15 echo " myalias = !echo in_config" >>.config/git/config &&
16 echo in_config >expected &&
17 git myalias >actual &&
18 test_cmp expected actual
22 test_expect_success
'read config: xdg file exists and ~/.gitconfig exists' '
24 echo "[alias]" >.gitconfig &&
25 echo " myalias = !echo in_gitconfig" >>.gitconfig &&
26 echo in_gitconfig >expected &&
27 git myalias >actual &&
28 test_cmp expected actual
32 test_expect_success
'read with --get: xdg file exists and ~/.gitconfig doesn'\''t' '
34 echo "[user]" >.config/git/config &&
35 echo " name = read_config" >>.config/git/config &&
36 echo read_config >expected &&
37 git config --get user.name >actual &&
38 test_cmp expected actual
42 test_expect_success
'read with --get: xdg file exists and ~/.gitconfig exists' '
44 echo "[user]" >.gitconfig &&
45 echo " name = read_gitconfig" >>.gitconfig &&
46 echo read_gitconfig >expected &&
47 git config --get user.name >actual &&
48 test_cmp expected actual
52 test_expect_success
'read with --list: xdg file exists and ~/.gitconfig doesn'\''t' '
54 echo user.name=read_config >expected &&
55 git config --global --list >actual &&
56 test_cmp expected actual
60 test_expect_success
'read with --list: xdg file exists and ~/.gitconfig exists' '
62 echo "[user]" >.gitconfig &&
63 echo " name = read_gitconfig" >>.gitconfig &&
64 echo user.name=read_gitconfig >expected &&
65 git config --global --list >actual &&
66 test_cmp expected actual
70 test_expect_success
'Setup' '
73 echo foo >to_be_excluded
77 test_expect_success
'Exclusion of a file in the XDG ignore file' '
78 mkdir -p "$HOME"/.config/git/ &&
79 echo to_be_excluded >"$HOME"/.config/git/ignore &&
80 test_must_fail git add to_be_excluded
84 test_expect_success
'Exclusion in both XDG and local ignore files' '
85 echo to_be_excluded >.gitignore &&
86 test_must_fail git add to_be_excluded
90 test_expect_success
'Exclusion in a non-XDG global ignore file' '
92 echo >"$HOME"/.config/git/ignore &&
93 echo to_be_excluded >"$HOME"/my_gitignore &&
94 git config core.excludesfile "$HOME"/my_gitignore &&
95 test_must_fail git add to_be_excluded