Jeff King | 02e5ba4 | 2008-01-01 01:17:34 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='Test wacky input to git config' |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | setup() { |
| 7 | (printf "[section]\n" && |
| 8 | printf " key = foo") >.git/config |
| 9 | } |
| 10 | |
| 11 | check() { |
| 12 | echo "$2" >expected |
Thomas Jarosch | e0b3cc0 | 2009-04-17 14:05:11 +0200 | [diff] [blame] | 13 | git config --get "$1" >actual 2>&1 |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 14 | test_cmp actual expected |
Jeff King | 02e5ba4 | 2008-01-01 01:17:34 -0500 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | test_expect_success 'modify same key' ' |
| 18 | setup && |
| 19 | git config section.key bar && |
| 20 | check section.key bar |
| 21 | ' |
| 22 | |
| 23 | test_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 | |
| 30 | test_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 Donlan | e5c349b | 2008-05-04 01:37:52 -0400 | [diff] [blame] | 37 | SECTION="test.q\"s\\sq'sp e.key" |
Nanako Shiraishi | 0cb0e14 | 2008-09-03 17:59:27 +0900 | [diff] [blame] | 38 | test_expect_success 'make sure git config escapes section names properly' ' |
Bryan Donlan | e5c349b | 2008-05-04 01:37:52 -0400 | [diff] [blame] | 39 | git config "$SECTION" bar && |
| 40 | check "$SECTION" bar |
| 41 | ' |
| 42 | |
Thomas Jarosch | e0b3cc0 | 2009-04-17 14:05:11 +0200 | [diff] [blame] | 43 | LONG_VALUE=$(printf "x%01021dx a" 7) |
| 44 | test_expect_success 'do not crash on special long config line' ' |
| 45 | setup && |
| 46 | git config section.key "$LONG_VALUE" && |
Erik Faye-Lund | e96c19c | 2011-04-10 22:54:18 +0200 | [diff] [blame] | 47 | check section.key "$LONG_VALUE" |
Thomas Jarosch | e0b3cc0 | 2009-04-17 14:05:11 +0200 | [diff] [blame] | 48 | ' |
| 49 | |
Jeff King | 02e5ba4 | 2008-01-01 01:17:34 -0500 | [diff] [blame] | 50 | test_done |