Merge branch 'jk/maint-commit-check-committer-early'
[gitweb.git] / t / t1306-xdg-files.sh
index 05103f54addde966b4c450101fba3403571ec737..3c75c3f2e7e8f980a83fa05db24cf64e7b1cd5a3 100755 (executable)
@@ -96,4 +96,63 @@ test_expect_success 'Exclusion in a non-XDG global ignore file' '
 '
 
 
+test_expect_success 'Checking attributes in the XDG attributes file' '
+       echo foo >f &&
+       git check-attr -a f >actual &&
+       test_line_count -eq 0 actual &&
+       echo "f attr_f" >"$HOME"/.config/git/attributes &&
+       echo "f: attr_f: set" >expected &&
+       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 &&
+       git check-attr -a f >actual &&
+       test_cmp expected actual
+'
+
+
+test_expect_success 'Checking attributes in a non-XDG global attributes file' '
+       test_might_fail rm .gitattributes &&
+       echo "f attr_f=test" >"$HOME"/my_gitattributes &&
+       git config core.attributesfile "$HOME"/my_gitattributes &&
+       echo "f: attr_f: test" >expected &&
+       git check-attr -a f >actual &&
+       test_cmp expected actual
+'
+
+
+test_expect_success 'write: xdg file exists and ~/.gitconfig doesn'\''t' '
+       mkdir -p "$HOME"/.config/git &&
+       >"$HOME"/.config/git/config &&
+       test_might_fail rm "$HOME"/.gitconfig &&
+       git config --global user.name "write_config" &&
+       echo "[user]" >expected &&
+       echo "  name = write_config" >>expected &&
+       test_cmp expected "$HOME"/.config/git/config
+'
+
+
+test_expect_success 'write: xdg file exists and ~/.gitconfig exists' '
+       >"$HOME"/.gitconfig &&
+       git config --global user.name "write_gitconfig" &&
+       echo "[user]" >expected &&
+       echo "  name = write_gitconfig" >>expected &&
+       test_cmp expected "$HOME"/.gitconfig
+'
+
+
+test_expect_success 'write: ~/.config/git/ exists and config file doesn'\''t' '
+       test_might_fail rm "$HOME"/.gitconfig &&
+       test_might_fail rm "$HOME"/.config/git/config &&
+       git config --global user.name "write_gitconfig" &&
+       echo "[user]" >expected &&
+       echo "  name = write_gitconfig" >>expected &&
+       test_cmp expected "$HOME"/.gitconfig
+'
+
+
 test_done