diff options
author | Jeff King <peff@peff.net> | 2024-03-27 09:19:22 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-27 16:48:54 +0100 |
commit | 9ccf3e9b22b6843892319b189fd7aed37c451420 (patch) | |
tree | aaf233162df938b5609b1961318d14d154e04f46 /t/t0030-stripspace.sh | |
parent | config: allow multi-byte core.commentChar (diff) | |
download | git-9ccf3e9b22b6843892319b189fd7aed37c451420.tar.xz git-9ccf3e9b22b6843892319b189fd7aed37c451420.zip |
config: add core.commentString
The core.commentChar code recently learned to accept more than a
single ASCII character. But using it is annoying with multiple versions
of Git, since older ones will reject it outright:
$ git.v2.44.0 -c core.commentchar=foo stripspace -s
error: core.commentChar should only be one ASCII character
fatal: unable to parse 'core.commentchar' from command-line config
Let's add an alias core.commentString. That's arguably a better name
anyway, since we now can handle strings, and it makes it possible to
have a config that works reasonably with both old and new versions of
Git (see the example in the documentation).
This is strictly an alias, so there's not much point in adding duplicate
tests; I added a single one to t0030 that exercises the alias code.
Note also that the error messages for invalid values will now show the
variable the config parser handed us, and thus will be normalized to
lowercase (rather than camelcase). A few tests in t0030 are adjusted to
match.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0030-stripspace.sh')
-rwxr-xr-x | t/t0030-stripspace.sh | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh index a161faf702..f10f42ff1e 100755 --- a/t/t0030-stripspace.sh +++ b/t/t0030-stripspace.sh @@ -401,14 +401,19 @@ test_expect_success 'strip comments with changed comment char' ' test -z "$(echo "; comment" | git -c core.commentchar=";" stripspace -s)" ' +test_expect_success 'strip comments with changed comment string' ' + test ! -z "$(echo "// comment" | git -c core.commentchar=// stripspace)" && + test -z "$(echo "// comment" | git -c core.commentchar="//" stripspace -s)" +' + test_expect_success 'newline as commentchar is forbidden' ' test_must_fail git -c core.commentChar="$LF" stripspace -s 2>err && - grep "core.commentChar cannot contain newline" err + grep "core.commentchar cannot contain newline" err ' test_expect_success 'empty commentchar is forbidden' ' test_must_fail git -c core.commentchar= stripspace -s 2>err && - grep "core.commentChar must have at least one character" err + grep "core.commentchar must have at least one character" err ' test_expect_success '-c with single line' ' |