mirror of
https://github.com/git/git.git
synced 2024-12-12 11:24:02 +08:00
e96c19c50f
parse_value in config.c has a static buffer of 1024 bytes that it parse the value into. This can sometimes be a problem when a config file contains very long values. It's particularly amusing that git-config already is able to write such files, so it should probably be able to read them as well. Fix this by using a strbuf instead of a fixed-size buffer. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
51 lines
1012 B
Bash
Executable File
51 lines
1012 B
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='Test wacky input to git config'
|
|
. ./test-lib.sh
|
|
|
|
setup() {
|
|
(printf "[section]\n" &&
|
|
printf " key = foo") >.git/config
|
|
}
|
|
|
|
check() {
|
|
echo "$2" >expected
|
|
git config --get "$1" >actual 2>&1
|
|
test_cmp actual expected
|
|
}
|
|
|
|
test_expect_success 'modify same key' '
|
|
setup &&
|
|
git config section.key bar &&
|
|
check section.key bar
|
|
'
|
|
|
|
test_expect_success 'add key in same section' '
|
|
setup &&
|
|
git config section.other bar &&
|
|
check section.key foo &&
|
|
check section.other bar
|
|
'
|
|
|
|
test_expect_success 'add key in different section' '
|
|
setup &&
|
|
git config section2.key bar &&
|
|
check section.key foo &&
|
|
check section2.key bar
|
|
'
|
|
|
|
SECTION="test.q\"s\\sq'sp e.key"
|
|
test_expect_success 'make sure git config escapes section names properly' '
|
|
git config "$SECTION" bar &&
|
|
check "$SECTION" bar
|
|
'
|
|
|
|
LONG_VALUE=$(printf "x%01021dx a" 7)
|
|
test_expect_success 'do not crash on special long config line' '
|
|
setup &&
|
|
git config section.key "$LONG_VALUE" &&
|
|
check section.key "$LONG_VALUE"
|
|
'
|
|
|
|
test_done
|