{"thread":{"id":"36675","subject":"Fwd: [Bug] - Processing commit message after amend","startedAt":"2014-05-16T10:18:07Z","lastAt":"2014-05-17T01:52:23Z","messageCount":17,"participants":["Michal Stasa","Duy Nguyen","David Kastrup","Nguyễn Thái Ngọc Duy","Felipe Contreras","Jonathan Nieder","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"241873","messageId":"CALy3b+m7YkYB+mPEnAQnjKFAwUS_PqCUFtuxzN7hwhmNfMrw3Q@mail.gmail.com","threadId":"36675","inReplyTo":null,"subject":"Fwd: [Bug] - Processing commit message after amend","fromName":"Michal Stasa","fromEmail":"michal.stasa@gmail.com","sentAt":"2014-05-16T10:18:07Z","receivedAt":"2014-05-16T10:18:07Z","isPatch":false,"sender":{"key":"michal.stasa@gmail.com","avatar":null},"body":"Hi,\n\nI have stumbled on a weird bug. At work, we use redmine as an issue\ntracker and its task are marked by a number starting with #. When I\ncommit some work and write #1234 in the message, it works. However,\nlater on when I remember that I forgot to add some files and amend the\ncommit, vim appears and I cannot perform the commit because the\nmessage starts with # which is a comment in vim and thus I get an\nerror that my commit message is empty.\n\nSteps to reproduce:\n1) commit a file\ngit commit File1.txt -m \"#1234 documentation added\"\n\n2) amend previous commit\ngit commit File2.txt -- amend\n\n3) go for :wq right away\n\n4) an error that the message is empty appears\n\"Aborting commit due to empty commit message\"\n\nHowever, if you use amend and no edit option, it works\ngit commit --amend --no-edit\n\nWe use git for Windows downloaded here:\nhttp://git-scm.com/downloads\n\nThe problem appears in Windows command line. I have not tested it\nanywhere else. The OS is Windows Server 2008 R2 Datacenter.\n\nCheers from cloudy Prague\nMichal Staša\n\nSanthos.net\nwww.santhos.net\n\n+420 773 454 793\nmichal.stasa@santhos.net\n"},{"id":"241874","messageId":"CACsJy8DSqeAnCMCawsh-58=B1z93tBCVb+x8XAAUZ17Y1ZaJKA@mail.gmail.com","threadId":"36675","inReplyTo":"CALy3b+m7YkYB+mPEnAQnjKFAwUS_PqCUFtuxzN7hwhmNfMrw3Q@mail.gmail.com","subject":"Re: [Bug] - Processing commit message after amend","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-16T10:28:57Z","receivedAt":"2014-05-16T10:28:57Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, May 16, 2014 at 5:18 PM, Michal Stasa <michal.stasa@gmail.com> wrote:\n> Hi,\n>\n> I have stumbled on a weird bug. At work, we use redmine as an issue\n> tracker and its task are marked by a number starting with #. When I\n> commit some work and write #1234 in the message, it works. However,\n> later on when I remember that I forgot to add some files and amend the\n> commit, vim appears and I cannot perform the commit because the\n> message starts with # which is a comment in vim and thus I get an\n> error that my commit message is empty.\n\nA workaround would be \"git -c core.commentChar=@ <command> ...\" (@\ncould be some other character). But maybe git should detect that the\ncurrent commit message has leading '#' and automatically switch to\nanother character..\n-- \nDuy\n"},{"id":"241877","messageId":"87mweif1w8.fsf@fencepost.gnu.org","threadId":"36675","inReplyTo":"CALy3b+m7YkYB+mPEnAQnjKFAwUS_PqCUFtuxzN7hwhmNfMrw3Q@mail.gmail.com","subject":"Re: Fwd: [Bug] - Processing commit message after amend","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2014-05-16T10:34:15Z","receivedAt":"2014-05-16T10:34:15Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Michal Stasa <michal.stasa@gmail.com> writes:\n\n> I have stumbled on a weird bug. At work, we use redmine as an issue\n> tracker and its task are marked by a number starting with #. When I\n> commit some work and write #1234 in the message, it works. However,\n> later on when I remember that I forgot to add some files and amend the\n> commit, vim appears and I cannot perform the commit because the\n> message starts with # which is a comment in vim and thus I get an\n> error that my commit message is empty.\n>\n> Steps to reproduce:\n> 1) commit a file\n> git commit File1.txt -m \"#1234 documentation added\"\n>\n> 2) amend previous commit\n> git commit File2.txt -- amend\n>\n> 3) go for :wq right away\n\ngit commit --amend -C HEAD File2.txt\n\nshould do the trick without starting the editor.\n\n> However, if you use amend and no edit option, it works\n> git commit --amend --no-edit\n\nAh, so you got your solution.  It's not like you could add that sort of\ncommit message interactively to start with, so it's not all that\nsurprising that you won't be able to amend it interactively.\n\n-- \nDavid Kastrup\n"},{"id":"241876","messageId":"CALy3b+mmc-67pkS_bG=4Uwg2g37NGPdebMvpP7uEv78f5fxaCw@mail.gmail.com","threadId":"36675","inReplyTo":"CACsJy8DSqeAnCMCawsh-58=B1z93tBCVb+x8XAAUZ17Y1ZaJKA@mail.gmail.com","subject":"Re: [Bug] - Processing commit message after amend","fromName":"Michal Stasa","fromEmail":"michal.stasa@gmail.com","sentAt":"2014-05-16T10:34:25Z","receivedAt":"2014-05-16T10:34:25Z","isPatch":false,"sender":{"key":"michal.stasa@gmail.com","avatar":null},"body":"It sounds like a good workaround but I think there could be a problem.\nWhen vim opens there is the message on the first line and two lines\nbelow is a commented text which uses # as comment char. Does the char\nchange when you change the comment char?\nMichal Staša\n\nSanthos.net\nwww.santhos.net\n\n+420 773 454 793\nmichal.stasa@santhos.net\n\n\nOn 16 May 2014 12:28, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Fri, May 16, 2014 at 5:18 PM, Michal Stasa <michal.stasa@gmail.com> wrote:\n>> Hi,\n>>\n>> I have stumbled on a weird bug. At work, we use redmine as an issue\n>> tracker and its task are marked by a number starting with #. When I\n>> commit some work and write #1234 in the message, it works. However,\n>> later on when I remember that I forgot to add some files and amend the\n>> commit, vim appears and I cannot perform the commit because the\n>> message starts with # which is a comment in vim and thus I get an\n>> error that my commit message is empty.\n>\n> A workaround would be \"git -c core.commentChar=@ <command> ...\" (@\n> could be some other character). But maybe git should detect that the\n> current commit message has leading '#' and automatically switch to\n> another character..\n> --\n> Duy\n"},{"id":"241878","messageId":"1400237982-5842-1-git-send-email-pclouds@gmail.com","threadId":"36675","inReplyTo":"CACsJy8DSqeAnCMCawsh-58=B1z93tBCVb+x8XAAUZ17Y1ZaJKA@mail.gmail.com","subject":"[PATCH] commit: switch core.commentChar if it's found in existing commit","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-16T10:59:42Z","receivedAt":"2014-05-16T10:59:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"If we need to use core.commentChar and it's already in the prepared\nmessage, find another char among a small subset. This should stop\nsurprises because git strips some lines unexpectedly. Of course if\ncandicate characters happen to be all out, this change does not help.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n On Fri, May 16, 2014 at 5:28 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n > But maybe git should detect that the\n > current commit message has leading '#' and automatically switch to\n > another character..\n\n Something like this. Lightly tested.. I know there's a small bug..\n\n builtin/commit.c | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 6ab4605..70ceb61 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -593,6 +593,32 @@ static char *cut_ident_timestamp_part(char *string)\n \treturn ket;\n }\n \n+static void adjust_comment_line_char(const struct strbuf *sb)\n+{\n+\tchar candidates[] = \" !@#$%^&|:;~\";\n+\tchar *candidate;\n+\tconst char *p;\n+\tif (!sb->len)\n+\t\treturn;\n+\tcandidates[0] = comment_line_char;\n+\tp = sb->buf;\n+\tdo {\n+\t\tcandidate = strchr(candidates, *p);\n+\t\tif (candidate)\n+\t\t\t*candidate = ' ';\n+\t\tp = strchrnul(p, '\\n');\n+\t\tif (*p)\n+\t\t\tp++;\n+\t} while (*p);\n+\tif (strchr(candidates, comment_line_char)) {\n+\t\tp = candidates;\n+\t\twhile (*p && *p == ' ')\n+\t\t\tp++;\n+\t\tif (*p)\n+\t\t\tcomment_line_char = *p;\n+\t}\n+}\n+\n static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t     struct commit *current_head,\n \t\t\t     struct wt_status *s,\n@@ -748,6 +774,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \tif (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)\n \t\tdie_errno(_(\"could not write commit template\"));\n \n+\tif (use_editor && include_status)\n+\t\tadjust_comment_line_char(&sb);\n+\n \tstrbuf_release(&sb);\n \n \t/* This checks if committer ident is explicitly given */\n-- \n1.9.1.346.ga2b5940\n"},{"id":"241888","messageId":"1400248283-303-1-git-send-email-pclouds@gmail.com","threadId":"36675","inReplyTo":"1400237982-5842-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 1/2] config: be strict on core.commentChar","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-16T13:51:22Z","receivedAt":"2014-05-16T13:51:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"We don't support comment _strings_ (at least not yet). And multi-byte\ncharacter encoding could also be misinterpreted.\n\nThe test with two commas is deleted because it violates this. It's\nadded with the patch that introduces core.commentChar in eff80a9\n(Allow custom \"comment char\" - 2013-01-16). It's not clear to me _why_\nthat behavior is wanted.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n config.c          | 8 ++++++--\n t/t7508-status.sh | 6 ------\n 2 files changed, 6 insertions(+), 8 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex a30cb5c..05d909b 100644\n--- a/config.c\n+++ b/config.c\n@@ -826,8 +826,12 @@ static int git_default_core_config(const char *var, const char *value)\n \tif (!strcmp(var, \"core.commentchar\")) {\n \t\tconst char *comment;\n \t\tint ret = git_config_string(&comment, var, value);\n-\t\tif (!ret)\n-\t\t\tcomment_line_char = comment[0];\n+\t\tif (!ret) {\n+\t\t\tif (comment[0] && !comment[1])\n+\t\t\t\tcomment_line_char = comment[0];\n+\t\t\telse\n+\t\t\t\treturn error(\"core.commentChar should only be one character\");\n+\t\t}\n \t\treturn ret;\n \t}\n \ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex c987b5e..98a9990 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1348,12 +1348,6 @@ test_expect_success \"status (core.commentchar with submodule summary)\" '\n \ttest_i18ncmp expect output\n '\n \n-test_expect_success \"status (core.commentchar with two chars with submodule summary)\" '\n-\ttest_config core.commentchar \";;\" &&\n-\tgit -c status.displayCommentPrefix=true status >output &&\n-\ttest_i18ncmp expect output\n-'\n-\n test_expect_success \"--ignore-submodules=all suppresses submodule summary\" '\n \tcat > expect << EOF &&\n On branch master\n-- \n1.9.1.346.ga2b5940\n"},{"id":"241889","messageId":"1400248283-303-2-git-send-email-pclouds@gmail.com","threadId":"36675","inReplyTo":"1400248283-303-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 2/2] commit: allow core.commentChar=auto for character auto selection","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-16T13:51:23Z","receivedAt":"2014-05-16T13:51:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"core.commentChar starts with '#' as in default but if it's already in\nthe prepared message, find another one among a small subset. This\nshould stop surprises because git strips some lines unexpectedly.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/config.txt |  3 +++\n builtin/commit.c         | 36 ++++++++++++++++++++++++++++++++++++\n cache.h                  |  1 +\n config.c                 |  2 ++\n environment.c            |  1 +\n t/t7502-commit.sh        | 25 +++++++++++++++++++++++++\n 6 files changed, 68 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 1932e9b..d5bf4d0 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -544,6 +544,9 @@ core.commentchar::\n \tmessages consider a line that begins with this character\n \tcommented, and removes them after the editor returns\n \t(default '#').\n++\n+If set to \"auto\", `git-commit` would select a character that is not\n+the beginning character of any line of existing commit messages.\n \n sequence.editor::\n \tText editor used by `git rebase -i` for editing the rebase instruction file.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 9cfef6c..039b426 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -594,6 +594,40 @@ static char *cut_ident_timestamp_part(char *string)\n \treturn ket;\n }\n \n+static void adjust_comment_line_char(const struct strbuf *sb)\n+{\n+\tchar candidates[] = \" @!#$%^&|:;~\";\n+\tchar *candidate;\n+\tconst char *p;\n+\n+\tif (!sb->len)\n+\t\treturn;\n+\n+\tif (!strchr(candidates, comment_line_char))\n+\t\tcandidates[0] = comment_line_char;\n+\tp = sb->buf;\n+\tcandidate = strchr(candidates, *p);\n+\tif (candidate)\n+\t\t*candidate = ' ';\n+\tfor (p = sb->buf; *p; p++) {\n+\t\tif ((p[0] == '\\n' || p[0] == '\\r') && p[1]) {\n+\t\t\tcandidate = strchr(candidates, p[1]);\n+\t\t\tif (candidate)\n+\t\t\t\t*candidate = ' ';\n+\t\t}\n+\t}\n+\n+\tif (candidates[0] == comment_line_char)\n+\t\treturn;\n+\tfor (p = candidates; *p == ' '; p++)\n+\t\t;\n+\tif (!*p)\n+\t\tdie(_(\"the comment character '%c' exists in the commit message\\n\"\n+\t\t      \"Please choose another character for core.commentChar\"),\n+\t\t    comment_line_char);\n+\tcomment_line_char = *p;\n+}\n+\n static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t     struct commit *current_head,\n \t\t\t     struct wt_status *s,\n@@ -748,6 +782,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \tif (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)\n \t\tdie_errno(_(\"could not write commit template\"));\n \n+\tif (auto_comment_line_char)\n+\t\tadjust_comment_line_char(&sb);\n \tstrbuf_release(&sb);\n \n \t/* This checks if committer ident is explicitly given */\ndiff --git a/cache.h b/cache.h\nindex 107ac61..646fb81 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -602,6 +602,7 @@ extern int precomposed_unicode;\n  * that is subject to stripspace.\n  */\n extern char comment_line_char;\n+extern int auto_comment_line_char;\n \n enum branch_track {\n \tBRANCH_TRACK_UNSPECIFIED = -1,\ndiff --git a/config.c b/config.c\nindex 05d909b..5ec3520 100644\n--- a/config.c\n+++ b/config.c\n@@ -829,6 +829,8 @@ static int git_default_core_config(const char *var, const char *value)\n \t\tif (!ret) {\n \t\t\tif (comment[0] && !comment[1])\n \t\t\t\tcomment_line_char = comment[0];\n+\t\t\telse if (!strcasecmp(comment, \"auto\"))\n+\t\t\t\tauto_comment_line_char = 1;\n \t\t\telse\n \t\t\t\treturn error(\"core.commentChar should only be one character\");\n \t\t}\ndiff --git a/environment.c b/environment.c\nindex 5c4815d..f2de1ee 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -69,6 +69,7 @@ unsigned long pack_size_limit_cfg;\n  * that is subject to stripspace.\n  */\n char comment_line_char = '#';\n+int auto_comment_line_char;\n \n /* Parallel index stat data preload? */\n int core_preload_index = 0;\ndiff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\nindex 9a3f3a1..5cff300 100755\n--- a/t/t7502-commit.sh\n+++ b/t/t7502-commit.sh\n@@ -563,4 +563,29 @@ test_expect_success 'commit --status with custom comment character' '\n \ttest_i18ngrep \"^; Changes to be committed:\" .git/COMMIT_EDITMSG\n '\n \n+test_expect_success 'switch core.commentchar' '\n+\ttest_commit \"#foo\" foo &&\n+\tGIT_EDITOR=.git/FAKE_EDITOR git -c core.commentChar=auto commit --amend &&\n+\ttest_i18ngrep \"^@ Changes to be committed:\" .git/COMMIT_EDITMSG\n+'\n+\n+test_expect_success 'switch core.commentchar but out of options' '\n+\tcat >text <<\\EOF &&\n+# 1\n+@ 2\n+! 3\n+$ 4\n+% 5\n+^ 6\n+& 7\n+| 8\n+: 9\n+; 10\n+~ 11\n+EOF\n+\tgit commit --amend -F text &&\n+\tGIT_EDITOR=.git/FAKE_EDITOR test_must_fail \\\n+\t\tgit -c core.commentChar=auto commit --amend\n+'\n+\n test_done\n-- \n1.9.1.346.ga2b5940\n"},{"id":"241905","messageId":"537623bf5f850_149cac13044a@nysa.notmuch","threadId":"36675","inReplyTo":"1400248283-303-1-git-send-email-pclouds@gmail.com","subject":"RE: [PATCH 1/2] config: be strict on core.commentChar","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2014-05-16T14:42:07Z","receivedAt":"2014-05-16T14:42:07Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n> We don't support comment _strings_ (at least not yet). And multi-byte\n> character encoding could also be misinterpreted.\n> \n> The test with two commas is deleted because it violates this. It's\n> added with the patch that introduces core.commentChar in eff80a9\n> (Allow custom \"comment char\" - 2013-01-16). It's not clear to me _why_\n> that behavior is wanted.\n> \n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  config.c          | 8 ++++++--\n>  t/t7508-status.sh | 6 ------\n>  2 files changed, 6 insertions(+), 8 deletions(-)\n> \n> diff --git a/config.c b/config.c\n> index a30cb5c..05d909b 100644\n> --- a/config.c\n> +++ b/config.c\n> @@ -826,8 +826,12 @@ static int git_default_core_config(const char *var, const char *value)\n>  \tif (!strcmp(var, \"core.commentchar\")) {\n>  \t\tconst char *comment;\n>  \t\tint ret = git_config_string(&comment, var, value);\n> -\t\tif (!ret)\n> -\t\t\tcomment_line_char = comment[0];\n> +\t\tif (!ret) {\n> +\t\t\tif (comment[0] && !comment[1])\n> +\t\t\t\tcomment_line_char = comment[0];\n> +\t\t\telse\n> +\t\t\t\treturn error(\"core.commentChar should only be one character\");\n> +\t\t}\n\nSmall nit:\n\n  if (ret)\n\t  return ret;\n  if (comment[0] && !comment[1])\n\t  comment_line_char = comment[0];\n  else\n\t  return error(\"core.commentChar should only be one character\");\n\n-- \nFelipe Contreras"},{"id":"241935","messageId":"20140516162508.GA12314@google.com","threadId":"36675","inReplyTo":"1400248283-303-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 1/2] config: be strict on core.commentChar","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-05-16T16:25:08Z","receivedAt":"2014-05-16T16:25:08Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> --- a/config.c\n> +++ b/config.c\n> @@ -826,8 +826,12 @@ static int git_default_core_config(const char *var, const char *value)\n>  \tif (!strcmp(var, \"core.commentchar\")) {\n>  \t\tconst char *comment;\n>  \t\tint ret = git_config_string(&comment, var, value);\n> -\t\tif (!ret)\n> -\t\t\tcomment_line_char = comment[0];\n> +\t\tif (!ret) {\n> +\t\t\tif (comment[0] && !comment[1])\n> +\t\t\t\tcomment_line_char = comment[0];\n> +\t\t\telse\n> +\t\t\t\treturn error(\"core.commentChar should only be one character\");\n> +\t\t}\n\nPerhaps, to decrease indentation a little:\n\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tif (comment[0] && !comment[1])\n\t\t\tcomment_line_char = comment[0];\n\t\telse\n\t\t\treturn error(...);\n\t\treturn 0;\n\n[...]\n> --- a/t/t7508-status.sh\n> +++ b/t/t7508-status.sh\n> @@ -1348,12 +1348,6 @@ test_expect_success \"status (core.commentchar with submodule summary)\" '\n>  \ttest_i18ncmp expect output\n>  '\n>  \n> -test_expect_success \"status (core.commentchar with two chars with submodule summary)\" '\n> -\ttest_config core.commentchar \";;\" &&\n> -\tgit -c status.displayCommentPrefix=true status >output &&\n> -\ttest_i18ncmp expect output\n\nCould keep the test to avoid regressions:\n\n\ttest_config core.commentchar \";;\" &&\n\ttest_must_fail git -c status.displayCommentPrefix=true status\n\nThanks,\nJonathan\n"},{"id":"241936","messageId":"20140516164053.GB12314@google.com","threadId":"36675","inReplyTo":"1400248283-303-2-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 2/2] commit: allow core.commentChar=auto for character auto selection","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-05-16T16:40:53Z","receivedAt":"2014-05-16T16:40:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> core.commentChar starts with '#' as in default but if it's already in\n> the prepared message, find another one among a small subset. This\n> should stop surprises because git strips some lines unexpectedly.\n\nProbably worth mentioning this only kicks in if someone explicitly\nconfigures [core] commentchar = auto.\n\nWould it be a goal to make 'auto' the default eventually if people\nturn out to like it?\n\n[...]\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -594,6 +594,40 @@ static char *cut_ident_timestamp_part(char *string)\n>  \treturn ket;\n>  }\n>  \n> +static void adjust_comment_line_char(const struct strbuf *sb)\n> +{\n> +\tchar candidates[] = \" @!#$%^&|:;~\";\n\nThis prefers '@' over '#'.  Intended?\n\n[...]\n> +\tchar *candidate;\n> +\tconst char *p;\n> +\n> +\tif (!sb->len)\n> +\t\treturn;\n> +\n> +\tif (!strchr(candidates, comment_line_char))\n> +\t\tcandidates[0] = comment_line_char;\n\nCould do\n\n\tif (!memchr(sb->buf, comment_line_char, sb->len))\n\t\treturn;\n\nto solve the precedence problem.  The comment_line_char not appearing\nin the message is the usual case and handling it separately means it\ngets handled faster.\n\n[...]\n> --- a/config.c\n> +++ b/config.c\n> @@ -829,6 +829,8 @@ static int git_default_core_config(const char *var, const char *value)\n>  \t\tif (!ret) {\n>  \t\t\tif (comment[0] && !comment[1])\n>  \t\t\t\tcomment_line_char = comment[0];\n> +\t\t\telse if (!strcasecmp(comment, \"auto\"))\n> +\t\t\t\tauto_comment_line_char = 1;\n\nIs there a way to disable 'auto' if 'auto' is already set?\n\ncomment_line_char still can be set and matters when 'auto' is set.\nShould they be separate settings?\n\n> --- a/t/t7502-commit.sh\n> +++ b/t/t7502-commit.sh\n> @@ -563,4 +563,29 @@ test_expect_success 'commit --status with custom comment character' '\n[...]\n> +\tGIT_EDITOR=.git/FAKE_EDITOR test_must_fail \\\n\nShells make it obnoxiously hard to set a one-shot envvar while\ncalling a function without the setting leaking into later commands.\n\n\t(\n\t\ttest_set_editor .git/FAKE_EDITOR &&\n\t\ttest_must_fail ...\n\t)\n\nor\n\n\ttest_must_fail env GIT_EDITOR=.git/FAKE_EDITOR ...\n\nshould do the trick.\n\nThanks and hope that helps,\nJonathan\n"},{"id":"241991","messageId":"xmqqzjihab2b.fsf@gitster.dls.corp.google.com","threadId":"36675","inReplyTo":"1400237982-5842-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] commit: switch core.commentChar if it's found in existing commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-16T17:27:24Z","receivedAt":"2014-05-16T17:27:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> If we need to use core.commentChar and it's already in the prepared\n> message, find another char among a small subset. This should stop\n> surprises because git strips some lines unexpectedly. Of course if\n> candicate characters happen to be all out, this change does not help.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  On Fri, May 16, 2014 at 5:28 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n>  > But maybe git should detect that the\n>  > current commit message has leading '#' and automatically switch to\n>  > another character..\n>\n>  Something like this. Lightly tested.. I know there's a small bug..\n>\n>  builtin/commit.c | 29 +++++++++++++++++++++++++++++\n>  1 file changed, 29 insertions(+)\n>\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index 6ab4605..70ceb61 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -593,6 +593,32 @@ static char *cut_ident_timestamp_part(char *string)\n>  \treturn ket;\n>  }\n>  \n> +static void adjust_comment_line_char(const struct strbuf *sb)\n> +{\n> +\tchar candidates[] = \" !@#$%^&|:;~\";\n\nDid you really mean to add a SP to the candidates?\n\n> +\tchar *candidate;\n> +\tconst char *p;\n> +\tif (!sb->len)\n> +\t\treturn;\n> +\tcandidates[0] = comment_line_char;\n> +\tp = sb->buf;\n> +\tdo {\n> +\t\tcandidate = strchr(candidates, *p);\n> +\t\tif (candidate)\n> +\t\t\t*candidate = ' ';\n> +\t\tp = strchrnul(p, '\\n');\n> +\t\tif (*p)\n> +\t\t\tp++;\n> +\t} while (*p);\n> +\tif (strchr(candidates, comment_line_char)) {\n> +\t\tp = candidates;\n> +\t\twhile (*p && *p == ' ')\n> +\t\t\tp++;\n> +\t\tif (*p)\n> +\t\t\tcomment_line_char = *p;\n> +\t}\n> +}\n> +\n>  static int prepare_to_commit(const char *index_file, const char *prefix,\n>  \t\t\t     struct commit *current_head,\n>  \t\t\t     struct wt_status *s,\n> @@ -748,6 +774,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n>  \tif (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)\n>  \t\tdie_errno(_(\"could not write commit template\"));\n>  \n> +\tif (use_editor && include_status)\n> +\t\tadjust_comment_line_char(&sb);\n> +\n>  \tstrbuf_release(&sb);\n>  \n>  \t/* This checks if committer ident is explicitly given */\n"},{"id":"241986","messageId":"xmqqsio9aank.fsf@gitster.dls.corp.google.com","threadId":"36675","inReplyTo":"20140516162508.GA12314@google.com","subject":"Re: [PATCH 1/2] config: be strict on core.commentChar","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-16T17:36:15Z","receivedAt":"2014-05-16T17:36:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Nguyễn Thái Ngọc Duy wrote:\n>\n>> --- a/config.c\n>> +++ b/config.c\n>> @@ -826,8 +826,12 @@ static int git_default_core_config(const char *var, const char *value)\n>>  \tif (!strcmp(var, \"core.commentchar\")) {\n>>  \t\tconst char *comment;\n>>  \t\tint ret = git_config_string(&comment, var, value);\n>> -\t\tif (!ret)\n>> -\t\t\tcomment_line_char = comment[0];\n>> +\t\tif (!ret) {\n>> +\t\t\tif (comment[0] && !comment[1])\n>> +\t\t\t\tcomment_line_char = comment[0];\n>> +\t\t\telse\n>> +\t\t\t\treturn error(\"core.commentChar should only be one character\");\n>> +\t\t}\n>\n> Perhaps, to decrease indentation a little:\n>\n> \t\tif (ret)\n> \t\t\treturn ret;\n> \t\tif (comment[0] && !comment[1])\n> \t\t\tcomment_line_char = comment[0];\n> \t\telse\n> \t\t\treturn error(...);\n> \t\treturn 0;\n>\n> [...]\n>> --- a/t/t7508-status.sh\n>> +++ b/t/t7508-status.sh\n>> @@ -1348,12 +1348,6 @@ test_expect_success \"status (core.commentchar with submodule summary)\" '\n>>  \ttest_i18ncmp expect output\n>>  '\n>>  \n>> -test_expect_success \"status (core.commentchar with two chars with submodule summary)\" '\n>> -\ttest_config core.commentchar \";;\" &&\n>> -\tgit -c status.displayCommentPrefix=true status >output &&\n>> -\ttest_i18ncmp expect output\n>\n> Could keep the test to avoid regressions:\n>\n> \ttest_config core.commentchar \";;\" &&\n> \ttest_must_fail git -c status.displayCommentPrefix=true status\n\nAll good points, including your other review message.\n"},{"id":"241987","messageId":"xmqqoayxaakf.fsf@gitster.dls.corp.google.com","threadId":"36675","inReplyTo":"20140516164053.GB12314@google.com","subject":"Re: [PATCH 2/2] commit: allow core.commentChar=auto for character auto selection","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-16T17:38:08Z","receivedAt":"2014-05-16T17:38:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Nguyễn Thái Ngọc Duy wrote:\n>\n>> core.commentChar starts with '#' as in default but if it's already in\n>> the prepared message, find another one among a small subset. This\n>> should stop surprises because git strips some lines unexpectedly.\n>\n> Probably worth mentioning this only kicks in if someone explicitly\n> configures [core] commentchar = auto.\n>\n> Would it be a goal to make 'auto' the default eventually if people\n> turn out to like it?\n>\n> [...]\n>> --- a/builtin/commit.c\n>> +++ b/builtin/commit.c\n>> @@ -594,6 +594,40 @@ static char *cut_ident_timestamp_part(char *string)\n>>  \treturn ket;\n>>  }\n>>  \n>> +static void adjust_comment_line_char(const struct strbuf *sb)\n>> +{\n>> +\tchar candidates[] = \" @!#$%^&|:;~\";\n>\n> This prefers '@' over '#'.  Intended?\n\nI think the candidates[0] will almost always be overridden with \"#\"\nso it probably does not matter in practice, but I tend to agree that\n\"#\" (and probably \";\") should come before all others.\n"},{"id":"241994","messageId":"xmqqbnuxa725.fsf@gitster.dls.corp.google.com","threadId":"36675","inReplyTo":"xmqqzjihab2b.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] commit: switch core.commentChar if it's found in existing commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-16T18:53:54Z","receivedAt":"2014-05-16T18:53:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> If we need to use core.commentChar and it's already in the prepared\n>> message, find another char among a small subset. This should stop\n>> surprises because git strips some lines unexpectedly. Of course if\n>> candicate characters happen to be all out, this change does not help.\n>>\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>>  On Fri, May 16, 2014 at 5:28 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n>>  > But maybe git should detect that the\n>>  > current commit message has leading '#' and automatically switch to\n>>  > another character..\n>>\n>>  Something like this. Lightly tested.. I know there's a small bug..\n>>\n>>  builtin/commit.c | 29 +++++++++++++++++++++++++++++\n>>  1 file changed, 29 insertions(+)\n>>\n>> diff --git a/builtin/commit.c b/builtin/commit.c\n>> index 6ab4605..70ceb61 100644\n>> --- a/builtin/commit.c\n>> +++ b/builtin/commit.c\n>> @@ -593,6 +593,32 @@ static char *cut_ident_timestamp_part(char *string)\n>>  \treturn ket;\n>>  }\n>>  \n>> +static void adjust_comment_line_char(const struct strbuf *sb)\n>> +{\n>> +\tchar candidates[] = \" !@#$%^&|:;~\";\n>\n> Did you really mean to add a SP to the candidates?\n\nPlease ignore this noise.  I realized that the SP is there only to\nbe overwritten in the meantime, and this is an old message sent out\nbefore that realization, just emerging from my mail provider's\noutbox.\n"},{"id":"242013","messageId":"CACsJy8ASmBV2ORZeDQ=GUAGcq80_Gz2zmv6MGysFAVNR4Hs3YA@mail.gmail.com","threadId":"36675","inReplyTo":"20140516164053.GB12314@google.com","subject":"Re: [PATCH 2/2] commit: allow core.commentChar=auto for character auto selection","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-16T23:41:19Z","receivedAt":"2014-05-16T23:41:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, May 16, 2014 at 11:40 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Nguyễn Thái Ngọc Duy wrote:\n>\n>> core.commentChar starts with '#' as in default but if it's already in\n>> the prepared message, find another one among a small subset. This\n>> should stop surprises because git strips some lines unexpectedly.\n>\n> Probably worth mentioning this only kicks in if someone explicitly\n> configures [core] commentchar = auto.\n>\n> Would it be a goal to make 'auto' the default eventually if people\n> turn out to like it?\n\nNo. I started this with a patch that does this automatically without a\nconfig knob. It broke git-commit with custom templates. It broke\n--cleanup=strip -e -F.. So people may want to put this in ~/.gitconfig\nbut it's their decision.\n\n>> --- a/builtin/commit.c\n>> +++ b/builtin/commit.c\n>> @@ -594,6 +594,40 @@ static char *cut_ident_timestamp_part(char *string)\n>>       return ket;\n>>  }\n>>\n>> +static void adjust_comment_line_char(const struct strbuf *sb)\n>> +{\n>> +     char candidates[] = \" @!#$%^&|:;~\";\n>\n> This prefers '@' over '#'.  Intended?\n\nIt used to be the order of keys 1, 2, 3... on qwerty keyboard, but I\nwas afraid ! may become history expansion in bash so I made @\npreferred over !. Will make # and ; higher priority.\n\n>> +     char *candidate;\n>> +     const char *p;\n>> +\n>> +     if (!sb->len)\n>> +             return;\n>> +\n>> +     if (!strchr(candidates, comment_line_char))\n>> +             candidates[0] = comment_line_char;\n>\n> Could do\n>\n>         if (!memchr(sb->buf, comment_line_char, sb->len))\n>                 return;\n>\n> to solve the precedence problem.  The comment_line_char not appearing\n> in the message is the usual case and handling it separately means it\n> gets handled faster.\n\nNow that we use \"auto\" to turn this on, the placeholder candidates[0]\ncould probably be removed, we know comment_line_char is '#' at this\npoint.\n\n>> --- a/config.c\n>> +++ b/config.c\n>> @@ -829,6 +829,8 @@ static int git_default_core_config(const char *var, const char *value)\n>>               if (!ret) {\n>>                       if (comment[0] && !comment[1])\n>>                               comment_line_char = comment[0];\n>> +                     else if (!strcasecmp(comment, \"auto\"))\n>> +                             auto_comment_line_char = 1;\n>\n> Is there a way to disable 'auto' if 'auto' is already set?\n>\n> comment_line_char still can be set and matters when 'auto' is set.\n> Should they be separate settings?\n\nI think the next core.commentChar should override the old one, so\nauto_comment_line_char should be clear when we set new value to\ncomment_line_char.\n-- \nDuy\n"},{"id":"242014","messageId":"1400291543-1371-1-git-send-email-pclouds@gmail.com","threadId":"36675","inReplyTo":"1400248283-303-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 1/2] config: be strict on core.commentChar","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-17T01:52:22Z","receivedAt":"2014-05-17T01:52:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"We don't support comment _strings_ (at least not yet). And multi-byte\ncharacter encoding could also be misinterpreted.\n\nThe test with two commas is updated because it violates this. It's\nadded with the patch that introduces core.commentChar in eff80a9\n(Allow custom \"comment char\" - 2013-01-16). It's not clear to me _why_\nthat behavior is wanted.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n config.c          | 8 ++++++--\n t/t7508-status.sh | 3 +--\n 2 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex a30cb5c..491a905 100644\n--- a/config.c\n+++ b/config.c\n@@ -826,9 +826,13 @@ static int git_default_core_config(const char *var, const char *value)\n \tif (!strcmp(var, \"core.commentchar\")) {\n \t\tconst char *comment;\n \t\tint ret = git_config_string(&comment, var, value);\n-\t\tif (!ret)\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t\telse if (comment[0] && !comment[1]) {\n \t\t\tcomment_line_char = comment[0];\n-\t\treturn ret;\n+\t\t} else\n+\t\t\treturn error(\"core.commentChar should only be one character\");\n+\t\treturn 0;\n \t}\n \n \tif (!strcmp(var, \"core.askpass\"))\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex c987b5e..148ab9e 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1350,8 +1350,7 @@ test_expect_success \"status (core.commentchar with submodule summary)\" '\n \n test_expect_success \"status (core.commentchar with two chars with submodule summary)\" '\n \ttest_config core.commentchar \";;\" &&\n-\tgit -c status.displayCommentPrefix=true status >output &&\n-\ttest_i18ncmp expect output\n+\ttest_must_fail git -c status.displayCommentPrefix=true status\n '\n \n test_expect_success \"--ignore-submodules=all suppresses submodule summary\" '\n-- \n1.9.1.346.ga2b5940\n"},{"id":"242015","messageId":"1400291543-1371-2-git-send-email-pclouds@gmail.com","threadId":"36675","inReplyTo":"1400291543-1371-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 2/2] commit: allow core.commentChar=auto for character auto selection","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-05-17T01:52:23Z","receivedAt":"2014-05-17T01:52:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"When core.commentChar is \"auto\", the comment char starts with '#' as\nin default but if it's already in the prepared message, find another\nchar in a small subset. This should stop surprises because git strips\nsome lines unexpectedly.\n\nNote that git is not smart enough to recognize '#' as the comment char\nin custom templates and convert it if the final comment char is\ndifferent. It thinks '#' lines in custom templates as part of the\ncommit message. So don't use this with custom templates.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/config.txt |  3 +++\n builtin/commit.c         | 32 ++++++++++++++++++++++++++++++++\n cache.h                  |  1 +\n config.c                 |  3 +++\n environment.c            |  1 +\n t/t7502-commit.sh        | 26 ++++++++++++++++++++++++++\n 6 files changed, 66 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 1932e9b..9f3ce06 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -544,6 +544,9 @@ core.commentchar::\n \tmessages consider a line that begins with this character\n \tcommented, and removes them after the editor returns\n \t(default '#').\n++\n+If set to \"auto\", `git-commit` would select a character that is not\n+the beginning character of any line in existing commit messages.\n \n sequence.editor::\n \tText editor used by `git rebase -i` for editing the rebase instruction file.\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 9cfef6c..515c4c4 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -594,6 +594,36 @@ static char *cut_ident_timestamp_part(char *string)\n \treturn ket;\n }\n \n+static void adjust_comment_line_char(const struct strbuf *sb)\n+{\n+\tchar candidates[] = \"#;@!$%^&|:\";\n+\tchar *candidate;\n+\tconst char *p;\n+\n+\tcomment_line_char = candidates[0];\n+\tif (!memchr(sb->buf, comment_line_char, sb->len))\n+\t\treturn;\n+\n+\tp = sb->buf;\n+\tcandidate = strchr(candidates, *p);\n+\tif (candidate)\n+\t\t*candidate = ' ';\n+\tfor (p = sb->buf; *p; p++) {\n+\t\tif ((p[0] == '\\n' || p[0] == '\\r') && p[1]) {\n+\t\t\tcandidate = strchr(candidates, p[1]);\n+\t\t\tif (candidate)\n+\t\t\t\t*candidate = ' ';\n+\t\t}\n+\t}\n+\n+\tfor (p = candidates; *p == ' '; p++)\n+\t\t;\n+\tif (!*p)\n+\t\tdie(_(\"unable to select a comment character that is not used\\n\"\n+\t\t      \"in the current commit message\"));\n+\tcomment_line_char = *p;\n+}\n+\n static int prepare_to_commit(const char *index_file, const char *prefix,\n \t\t\t     struct commit *current_head,\n \t\t\t     struct wt_status *s,\n@@ -748,6 +778,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \tif (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)\n \t\tdie_errno(_(\"could not write commit template\"));\n \n+\tif (auto_comment_line_char)\n+\t\tadjust_comment_line_char(&sb);\n \tstrbuf_release(&sb);\n \n \t/* This checks if committer ident is explicitly given */\ndiff --git a/cache.h b/cache.h\nindex 107ac61..646fb81 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -602,6 +602,7 @@ extern int precomposed_unicode;\n  * that is subject to stripspace.\n  */\n extern char comment_line_char;\n+extern int auto_comment_line_char;\n \n enum branch_track {\n \tBRANCH_TRACK_UNSPECIFIED = -1,\ndiff --git a/config.c b/config.c\nindex 491a905..d29c733 100644\n--- a/config.c\n+++ b/config.c\n@@ -828,8 +828,11 @@ static int git_default_core_config(const char *var, const char *value)\n \t\tint ret = git_config_string(&comment, var, value);\n \t\tif (ret)\n \t\t\treturn ret;\n+\t\telse if (!strcasecmp(comment, \"auto\"))\n+\t\t\tauto_comment_line_char = 1;\n \t\telse if (comment[0] && !comment[1]) {\n \t\t\tcomment_line_char = comment[0];\n+\t\t\tauto_comment_line_char = 0;\n \t\t} else\n \t\t\treturn error(\"core.commentChar should only be one character\");\n \t\treturn 0;\ndiff --git a/environment.c b/environment.c\nindex 5c4815d..f2de1ee 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -69,6 +69,7 @@ unsigned long pack_size_limit_cfg;\n  * that is subject to stripspace.\n  */\n char comment_line_char = '#';\n+int auto_comment_line_char;\n \n /* Parallel index stat data preload? */\n int core_preload_index = 0;\ndiff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\nindex 9a3f3a1..30e4688 100755\n--- a/t/t7502-commit.sh\n+++ b/t/t7502-commit.sh\n@@ -563,4 +563,30 @@ test_expect_success 'commit --status with custom comment character' '\n \ttest_i18ngrep \"^; Changes to be committed:\" .git/COMMIT_EDITMSG\n '\n \n+test_expect_success 'switch core.commentchar' '\n+\ttest_commit \"#foo\" foo &&\n+\tGIT_EDITOR=.git/FAKE_EDITOR git -c core.commentChar=auto commit --amend &&\n+\ttest_i18ngrep \"^; Changes to be committed:\" .git/COMMIT_EDITMSG\n+'\n+\n+test_expect_success 'switch core.commentchar but out of options' '\n+\tcat >text <<\\EOF &&\n+# 1\n+; 2\n+@ 3\n+! 4\n+$ 5\n+% 6\n+^ 7\n+& 8\n+| 9\n+: 10\n+EOF\n+\tgit commit --amend -F text &&\n+\t(\n+\t\ttest_set_editor .git/FAKE_EDITOR &&\n+\t\ttest_must_fail git -c core.commentChar=auto commit --amend\n+\t)\n+'\n+\n test_done\n-- \n1.9.1.346.ga2b5940\n"}]}