5b971d93ebe6c1b2f0bddebc48635b2cfa389d5c
1#!/bin/sh
2#
3# Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
4# Thomas Nguy, Khoi Nguyen
5# Grenoble INP Ensimag
6#
7
8test_description='Compatibility with $XDG_CONFIG_HOME/git/ files'
9
10. ./test-lib.sh
11
12test_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
19'
20
21
22test_expect_success 'read config: xdg file exists and ~/.gitconfig exists' '
23 >.gitconfig &&
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
29'
30
31
32test_expect_success 'read with --get: xdg file exists and ~/.gitconfig doesn'\''t' '
33 rm .gitconfig &&
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
39'
40
41
42test_expect_success 'read with --get: xdg file exists and ~/.gitconfig exists' '
43 >.gitconfig &&
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
49'
50
51
52test_expect_success 'read with --list: xdg file exists and ~/.gitconfig doesn'\''t' '
53 rm .gitconfig &&
54 echo user.name=read_config >expected &&
55 git config --global --list >actual &&
56 test_cmp expected actual
57'
58
59
60test_expect_success 'read with --list: xdg file exists and ~/.gitconfig exists' '
61 >.gitconfig &&
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
67'
68
69
70test_done