]> git.ipfire.org Git - thirdparty/git.git/commit
config: allow multi-byte core.commentChar
authorJeff King <peff@peff.net>
Tue, 12 Mar 2024 09:17:50 +0000 (05:17 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Mar 2024 20:28:11 +0000 (13:28 -0700)
commit8b311478ad16b2fe9d2f5b5febec9f5e8f7fd52d
tree5419196101a12706b4bce2a250b63ad98f81c425
parent103d563f3716385080594f54ae312cc32bf7ec4d
config: allow multi-byte core.commentChar

Now that all of the code handles multi-byte comment characters, it's
safe to allow users to set them.

There is one special case I kept: we still will not allow an empty
string for the commentChar. While it might make sense in some contexts
(e.g., output where you don't want any comment prefix), there are plenty
where it will behave badly (e.g., all of our starts_with() checks will
indicate that every line is a comment!). It might be reasonable to
assign some meaningful semantics, but it would probably involve checking
how each site behaves. In the interim let's forbid it and we can loosen
things later.

Likewise, the "commentChar cannot be a newline" rule is now extended to
"it cannot contain a newline" (for the same reason: it can confuse our
parsing loops).

Since comment_line_str is used in many parts of the code, it's hard to
cover all possibilities with tests. We can convert the existing
double-semicolon prefix test to show that "git status" works. And we'll
give it a more challenging case in t7507, where we confirm that
git-commit strips out the commit template along with any --verbose text
when reading the edited commit message back in. That covers the basics,
though it's possible there could be issues in more exotic spots (e.g.,
the sequencer todo list uses its own code).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/core.txt
config.c
t/t0030-stripspace.sh
t/t7507-commit-verbose.sh
t/t7508-status.sh