summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-05-17 01:52:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-05-19 20:37:25 (GMT)
commit84c9dc2c5a2d34351a06554af32501d4f99990e9 (patch)
tree737dde6bdaab102e46f8694558c3645aaeecb1fa /config.c
parent50b54fd72a8776d628365c7760bc922902d29d11 (diff)
downloadgit-84c9dc2c5a2d34351a06554af32501d4f99990e9.zip
git-84c9dc2c5a2d34351a06554af32501d4f99990e9.tar.gz
git-84c9dc2c5a2d34351a06554af32501d4f99990e9.tar.bz2
commit: allow core.commentChar=auto for character auto selection
When core.commentChar is "auto", the comment char starts with '#' as in default but if it's already in the prepared message, find another char in a small subset. This should stop surprises because git strips some lines unexpectedly. Note that git is not smart enough to recognize '#' as the comment char in custom templates and convert it if the final comment char is different. It thinks '#' lines in custom templates as part of the commit message. So don't use this with custom templates. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/config.c b/config.c
index 491a905..d29c733 100644
--- a/config.c
+++ b/config.c
@@ -828,8 +828,11 @@ static int git_default_core_config(const char *var, const char *value)
int ret = git_config_string(&comment, var, value);
if (ret)
return ret;
+ else if (!strcasecmp(comment, "auto"))
+ auto_comment_line_char = 1;
else if (comment[0] && !comment[1]) {
comment_line_char = comment[0];
+ auto_comment_line_char = 0;
} else
return error("core.commentChar should only be one character");
return 0;