Skip to content

Commit 50b54fd

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6308767 commit 50b54fd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

config.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,9 +826,13 @@ static int git_default_core_config(const char *var, const char *value)
826826
if (!strcmp(var, "core.commentchar")) {
827827
const char *comment;
828828
int ret = git_config_string(&comment, var, value);
829-
if (!ret)
829+
if (ret)
830+
return ret;
831+
else if (comment[0] && !comment[1]) {
830832
comment_line_char = comment[0];
831-
return ret;
833+
} else
834+
return error("core.commentChar should only be one character");
835+
return 0;
832836
}
833837

834838
if (!strcmp(var, "core.askpass"))

t/t7508-status.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,7 @@ test_expect_success "status (core.commentchar with submodule summary)" '
13501350

13511351
test_expect_success "status (core.commentchar with two chars with submodule summary)" '
13521352
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
13551354
'
13561355

13571356
test_expect_success "--ignore-submodules=all suppresses submodule summary" '

0 commit comments

Comments
 (0)