blob: 46103a1591680c9803588d24a135abf79fe64ae9 [file] [log] [blame]
Jeff King02e5ba42008-01-01 01:17:34 -05001#!/bin/sh
2
3test_description='Test wacky input to git config'
4. ./test-lib.sh
5
6setup() {
7 (printf "[section]\n" &&
8 printf " key = foo") >.git/config
9}
10
11check() {
12 echo "$2" >expected
Thomas Jarosche0b3cc02009-04-17 14:05:11 +020013 git config --get "$1" >actual 2>&1
Junio C Hamano3af82862008-05-23 22:28:56 -070014 test_cmp actual expected
Jeff King02e5ba42008-01-01 01:17:34 -050015}
16
17test_expect_success 'modify same key' '
18 setup &&
19 git config section.key bar &&
20 check section.key bar
21'
22
23test_expect_success 'add key in same section' '
24 setup &&
25 git config section.other bar &&
26 check section.key foo &&
27 check section.other bar
28'
29
30test_expect_success 'add key in different section' '
31 setup &&
32 git config section2.key bar &&
33 check section.key foo &&
34 check section2.key bar
35'
36
Bryan Donlane5c349b2008-05-04 01:37:52 -040037SECTION="test.q\"s\\sq'sp e.key"
Nanako Shiraishi0cb0e142008-09-03 17:59:27 +090038test_expect_success 'make sure git config escapes section names properly' '
Bryan Donlane5c349b2008-05-04 01:37:52 -040039 git config "$SECTION" bar &&
40 check "$SECTION" bar
41'
42
Thomas Jarosche0b3cc02009-04-17 14:05:11 +020043LONG_VALUE=$(printf "x%01021dx a" 7)
44test_expect_success 'do not crash on special long config line' '
45 setup &&
46 git config section.key "$LONG_VALUE" &&
Erik Faye-Lunde96c19c2011-04-10 22:54:18 +020047 check section.key "$LONG_VALUE"
Thomas Jarosche0b3cc02009-04-17 14:05:11 +020048'
49
Jeff King02e5ba42008-01-01 01:17:34 -050050test_done