]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t1303-wacky-config.sh
3 test_description
='Test wacky input to git config'
6 # Leaving off the newline is intentional!
8 (printf "[section]\n" &&
9 printf " key = foo") >.git
/config
12 # 'check section.key value' verifies that the entry for section.key is
16 git config
--get "$1" >actual
2>&1
17 test_cmp expected actual
20 # 'check section.key regex value' verifies that the entry for
21 # section.key *that matches 'regex'* is 'value'
24 git config
--get "$1" "$2" >actual
2>&1
25 test_cmp expected actual
28 test_expect_success
'modify same key' '
30 git config section.key bar &&
34 test_expect_success
'add key in same section' '
36 git config section.other bar &&
37 check section.key foo &&
38 check section.other bar
41 test_expect_success
'add key in different section' '
43 git config section2.key bar &&
44 check section.key foo &&
45 check section2.key bar
48 SECTION
="test.q\"s\\sq'sp e.key"
49 test_expect_success
'make sure git config escapes section names properly' '
50 git config "$SECTION" bar &&
54 LONG_VALUE
=$
(printf "x%01021dx a" 7)
55 test_expect_success
'do not crash on special long config line' '
57 git config section.key "$LONG_VALUE" &&
58 check section.key "$LONG_VALUE"
63 # This time we want the newline so that we can tack on more
66 # Semi-efficient way of concatenating 5^5 = 3125 lines. Note
67 # that because 'setup' already put one line, this means 3126
68 # entries for section.key in the config file.
76 cat 5to1 5to1 5to1 5to1 5to1 >5to2 && # 25
77 cat 5to2 5to2 5to2 5to2 5to2 >5to3 && # 125
78 cat 5to3 5to3 5to3 5to3 5to3 >5to4 && # 635
79 cat 5to4 5to4 5to4 5to4 5to4 >>.git/config # 3125
82 test_expect_success 'get many entries' '
84 git config --get-all section.key >actual &&
85 test_line_count = 3126 actual
88 test_expect_success 'get many entries by regex' '
90 git config --get-regexp "sec.*ke." >actual &&
91 test_line_count = 3126 actual
94 test_expect_success 'add and replace one of many entries' '
96 git config --add section.key bar &&
97 check_regex section.key "b.*r" bar &&
98 git config section.key beer "b.*r" &&
99 check_regex section.key "b.*r" beer
102 test_expect_success 'replace many entries' '
104 git config --replace-all section.key bar &&
105 check section.key bar
108 test_expect_success 'unset many entries' '
110 git config --unset-all section.key &&
111 test_must_fail git config section.key
114 test_expect_success '--add appends new value after existing empty value' '
115 cat >expect <<-\
EOF &&
121 cp .git/config .git/config.old &&
122 test_when_finished "mv .git/config.old .git/config" &&
123 cat >.git/config <<-\EOF &&
129 git config --add foo.baz roll &&
130 git config --get-all foo.baz >output &&
131 test_cmp expect output