aboutsummaryrefslogtreecommitdiff
path: root/t/t7502-commit.sh
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-05-17 08:52:23 +0700
committerJunio C Hamano <gitster@pobox.com>2014-05-19 13:37:25 -0700
commit84c9dc2c5a2d34351a06554af32501d4f99990e9 (patch)
tree737dde6bdaab102e46f8694558c3645aaeecb1fa /t/t7502-commit.sh
parent50b54fd72a8776d628365c7760bc922902d29d11 (diff)
downloadgit-84c9dc2c5a2d34351a06554af32501d4f99990e9.tar.gz
git-84c9dc2c5a2d34351a06554af32501d4f99990e9.tar.xz
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 't/t7502-commit.sh')
-rwxr-xr-xt/t7502-commit.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 9a3f3a1b4..30e46884f 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -563,4 +563,30 @@ test_expect_success 'commit --status with custom comment character' '
test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG
'
+test_expect_success 'switch core.commentchar' '
+ test_commit "#foo" foo &&
+ GIT_EDITOR=.git/FAKE_EDITOR git -c core.commentChar=auto commit --amend &&
+ test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG
+'
+
+test_expect_success 'switch core.commentchar but out of options' '
+ cat >text <<\EOF &&
+# 1
+; 2
+@ 3
+! 4
+$ 5
+% 6
+^ 7
+& 8
+| 9
+: 10
+EOF
+ git commit --amend -F text &&
+ (
+ test_set_editor .git/FAKE_EDITOR &&
+ test_must_fail git -c core.commentChar=auto commit --amend
+ )
+'
+
test_done