summaryrefslogtreecommitdiff
path: root/t/t1300-repo-config.sh
diff options
context:
space:
mode:
authorMartin Stenberg <martin@gnutiken.se>2012-03-09 21:57:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-03-12 16:39:06 (GMT)
commit4b340593551217904d794cc0a8db55db89b5b066 (patch)
treecc73f2727a638a51a40e688008f4d0709b0331c4 /t/t1300-repo-config.sh
parentd909e0761c234b28aac77566368c1ee5451a856a (diff)
downloadgit-4b340593551217904d794cc0a8db55db89b5b066.zip
git-4b340593551217904d794cc0a8db55db89b5b066.tar.gz
git-4b340593551217904d794cc0a8db55db89b5b066.tar.bz2
config: report errors at the EOL with correct line number
A section in a config file with a missing "]" reports the next line as bad, same goes to a value with a missing end quote. This happens because the error is not detected until the end of the line, when line number is already increased. Fix this by decreasing line number by one for these cases. Signed-off-by: Martin Stenberg <martin@gnutiken.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1300-repo-config.sh')
-rwxr-xr-xt/t1300-repo-config.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index dffccf8..23c8711 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -928,4 +928,35 @@ test_expect_success 'git -c complains about empty key and value' '
test_must_fail git -c "" rev-parse
'
+# malformed configuration files
+test_expect_success 'barf on syntax error' '
+ cat >.git/config <<-\EOF &&
+ # broken section line
+ [section]
+ key garbage
+ EOF
+ test_must_fail git config --get section.key >actual 2>error &&
+ grep " line 3 " error
+'
+
+test_expect_success 'barf on incomplete section header' '
+ cat >.git/config <<-\EOF &&
+ # broken section line
+ [section
+ key = value
+ EOF
+ test_must_fail git config --get section.key >actual 2>error &&
+ grep " line 2 " error
+'
+
+test_expect_success 'barf on incomplete string' '
+ cat >.git/config <<-\EOF &&
+ # broken section line
+ [section]
+ key = "value string
+ EOF
+ test_must_fail git config --get section.key >actual 2>error &&
+ grep " line 3 " error
+'
+
test_done