config: be strict on core.commentChar
We don't support comment _strings_ (at least not yet). And multi-byte character encoding could also be misinterpreted. The test with two commas is updated because it violates this. It's added with the patch that introduces core.commentChar in eff80a9 (Allow custom "comment char" - 2013-01-16). It's not clear to me _why_ that behavior is wanted. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
May 17, 2014 at 08:52 UTC
50b54fd72a8776d628365c7760bc922902d29d11
2 files changed
+7
-4
config.c
+6
-2
@@ -826,9 +826,13 @@ static int git_default_core_config(const char *var, const char *value)
826
if (!strcmp(var, "core.commentchar")) {
827
const char *comment;
828
int ret = git_config_string(&comment, var, value);
829
- if (!ret)
829
+ if (ret)
830
+ return ret;
831
+ else if (comment[0] && !comment[1]) {
832
comment_line_char = comment[0];
831
- return ret;
833
+ } else
834
+ return error("core.commentChar should only be one character");
835
+ return 0;
836
}
837
838
if (!strcmp(var, "core.askpass"))
t/t7508-status.sh
+1
-2
@@ -1350,8 +1350,7 @@ test_expect_success "status (core.commentchar with submodule summary)" '
1350
1351
test_expect_success "status (core.commentchar with two chars with submodule summary)" '
1352
test_config core.commentchar ";;" &&
1353
- git -c status.displayCommentPrefix=true status >output &&
1354
- test_i18ncmp expect output
1353
+ test_must_fail git -c status.displayCommentPrefix=true status
1354
'
1355
1356
test_expect_success "--ignore-submodules=all suppresses submodule summary" '