This test already has impeccable style, with one exception: there is an unnecessary use of a subshell. Use a {} block instead. While at it: - guard setup commands with test_expect_success, so the commands are printed when the test is run with "-v" and errors in setup can be caught; - use echo instead of printf to print simple text ending with a newline, so the later use of printf stands out more; - put a single space before () in function definitions, for consistency with other shell scripts in git; - reorder arguments to test_cmp as "test_cmp expected actual". Cc: Jeff King <peff@xxxxxxxx> Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- t/t1303-wacky-config.sh | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh index 080117c..ce7ce1c 100755 --- a/t/t1303-wacky-config.sh +++ b/t/t1303-wacky-config.sh @@ -3,16 +3,20 @@ 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 'setup: helper functions' ' + setup () { + { + echo "[section]" && + printf " key = foo" + } >.git/config + } && + + check () { + echo "$2" >expected + git config --get "$1" >actual 2>&1 + test_cmp expected actual + } +' test_expect_success 'modify same key' ' setup && @@ -34,14 +38,14 @@ test_expect_success 'add key in different section' ' check section2.key bar ' -SECTION="test.q\"s\\sq'sp e.key" test_expect_success 'make sure git config escapes section names properly' ' + SECTION="test.q\"s\\sq'\''sp e.key" && 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' ' + LONG_VALUE=$(printf "x%01021dx a" 7) && setup && git config section.key "$LONG_VALUE" && check section.key "fatal: bad config file line 2 in .git/config" -- 1.7.2.3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html