{"thread":{"id":"39941","subject":"Log messages beginning # and git rebase -i","startedAt":"2015-07-27T11:38:23Z","lastAt":"2019-04-22T10:06:20Z","messageCount":18,"participants":["Ed Avis","Eric Sunshine","Duy Nguyen","Matthieu Moy","Junio C Hamano","Corentin BOMPARD"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"266821","messageId":"loom.20150727T133256-715@post.gmane.org","threadId":"39941","inReplyTo":null,"subject":"Log messages beginning # and git rebase -i","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-07-27T11:38:23Z","receivedAt":"2015-07-27T11:38:23Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"git commit will happily let you specify log messages beginning with #.\nBut then on git rebase -i, when squashing some commits, the editing for the\ncombined log message treats lines beginning with # as comments.  This means\nthat if you are not careful the commit message can get lost on rebasing.\n\nI suggest that git rebase should add an extra space at the start of existing\nlog message lines which begin with #.  That is a bit of a kludge but it is\nbetter than losing them because they got mixed up with comments.\n\n-- \nEd Avis <eda@waniasset.com>\n"},{"id":"266874","messageId":"CAPig+cRT6=YCHz+phfE+84y27ey-6ScjPxP2cHiVqumJmR6mOw@mail.gmail.com","threadId":"39941","inReplyTo":"loom.20150727T133256-715@post.gmane.org","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-07-27T23:25:16Z","receivedAt":"2015-07-27T23:25:16Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Jul 27, 2015 at 7:38 AM, Ed Avis <eda@waniasset.com> wrote:\n> git commit will happily let you specify log messages beginning with #.\n> But then on git rebase -i, when squashing some commits, the editing for the\n> combined log message treats lines beginning with # as comments.  This means\n> that if you are not careful the commit message can get lost on rebasing.\n>\n> I suggest that git rebase should add an extra space at the start of existing\n> log message lines which begin with #.  That is a bit of a kludge but it is\n> better than losing them because they got mixed up with comments.\n\n'git rebase --interactive' respects the core.commentChar configuration\nvariable, which you can set to some value other than '#'.\n"},{"id":"266877","messageId":"CACsJy8BE8GOj6g-pH7UgQ6sEQk_ZbtgqHkAHQvTkCDJU=2dBYw@mail.gmail.com","threadId":"39941","inReplyTo":"CAPig+cRT6=YCHz+phfE+84y27ey-6ScjPxP2cHiVqumJmR6mOw@mail.gmail.com","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-07-28T00:53:55Z","receivedAt":"2015-07-28T00:53:55Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jul 28, 2015 at 6:25 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Mon, Jul 27, 2015 at 7:38 AM, Ed Avis <eda@waniasset.com> wrote:\n>> git commit will happily let you specify log messages beginning with #.\n>> But then on git rebase -i, when squashing some commits, the editing for the\n>> combined log message treats lines beginning with # as comments.  This means\n>> that if you are not careful the commit message can get lost on rebasing.\n>>\n>> I suggest that git rebase should add an extra space at the start of existing\n>> log message lines which begin with #.  That is a bit of a kludge but it is\n>> better than losing them because they got mixed up with comments.\n>\n> 'git rebase --interactive' respects the core.commentChar configuration\n> variable, which you can set to some value other than '#'.\n\nYeah. I recommend setting it to 'auto' so it will pick an unused\ncharacter as separator (most of the time, don't push it too hard)\n-- \nDuy\n"},{"id":"266916","messageId":"loom.20150728T115023-269@post.gmane.org","threadId":"39941","inReplyTo":"CAPig+cRT6=YCHz+phfE+84y27ey-6ScjPxP2cHiVqumJmR6mOw@mail.gmail.com","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-07-28T09:51:40Z","receivedAt":"2015-07-28T09:51:40Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"Eric Sunshine <sunshine <at> sunshineco.com> writes:\n\n>>the editing for the\n>>combined log message treats lines beginning with # as comments.  This means\n>>that if you are not careful the commit message can get lost on rebasing.\n>>\n>>I suggest that git rebase should add an extra space at the start\n\n>'git rebase --interactive' respects the core.commentChar configuration\n>variable, which you can set to some value other than '#'.\n\nI was thinking of the default configuration.  But you are right, this applies\nto whatever the comment character is - so if commentChar is set to * for\nexample, then log lines beginning with * should get an extra space prepended\nin git rebase --interactive so that they don't get lost.\n\n-- \nEd Avis <eda@waniasset.com> \n"},{"id":"266928","messageId":"vpqsi88qp6q.fsf@anie.imag.fr","threadId":"39941","inReplyTo":"loom.20150728T115023-269@post.gmane.org","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-07-28T15:25:49Z","receivedAt":"2015-07-28T15:25:49Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ed Avis <eda@waniasset.com> writes:\n\n> Eric Sunshine <sunshine <at> sunshineco.com> writes:\n>\n>>>the editing for the\n>>>combined log message treats lines beginning with # as comments.  This means\n>>>that if you are not careful the commit message can get lost on rebasing.\n>>>\n>>>I suggest that git rebase should add an extra space at the start\n>\n>>'git rebase --interactive' respects the core.commentChar configuration\n>>variable, which you can set to some value other than '#'.\n>\n> I was thinking of the default configuration.  But you are right, this applies\n> to whatever the comment character is - so if commentChar is set to * for\n> example, then log lines beginning with * should get an extra space prepended\n> in git rebase --interactive so that they don't get lost.\n\nActually, is there any reason why we do not allow a simple escaping like\n\n\\# this is a line starting with #\n\\\\ this is a line starting with \\\n# this is a comment\n\n?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"266937","messageId":"xmqqr3nsfdmw.fsf@gitster.dls.corp.google.com","threadId":"39941","inReplyTo":"vpqsi88qp6q.fsf@anie.imag.fr","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-28T16:30:47Z","receivedAt":"2015-07-28T16:30:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Ed Avis <eda@waniasset.com> writes:\n>\n>> Eric Sunshine <sunshine <at> sunshineco.com> writes:\n>>\n>>>>the editing for the\n>>>>combined log message treats lines beginning with # as comments.  This means\n>>>>that if you are not careful the commit message can get lost on rebasing.\n>>>>\n>>>>I suggest that git rebase should add an extra space at the start\n>>\n>>>'git rebase --interactive' respects the core.commentChar configuration\n>>>variable, which you can set to some value other than '#'.\n>>\n>> I was thinking of the default configuration.  But you are right, this applies\n>> to whatever the comment character is - so if commentChar is set to * for\n>> example, then log lines beginning with * should get an extra space prepended\n>> in git rebase --interactive so that they don't get lost.\n>\n> Actually, is there any reason why we do not allow a simple escaping like\n>\n> \\# this is a line starting with #\n> \\\\ this is a line starting with \\\n> # this is a comment\n\nWhat are we trying to achieve?\n\nMunging the original \"# I want this line intact\" to any other form\nlike \" # I want this...\" is as bad as losing it.  If the user wants\nwhatever she types in the resulting commit literally, there is the\n\"--cleanup=<choice>\" option, no?\n"},{"id":"266939","messageId":"loom.20150728T183310-319@post.gmane.org","threadId":"39941","inReplyTo":"xmqqr3nsfdmw.fsf@gitster.dls.corp.google.com","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-07-28T16:40:10Z","receivedAt":"2015-07-28T16:40:10Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"I was considering this case:\n\n- git commit -a '-m# characters are now handled OK'\n- hack, hack\n- git commit -a '-mWhoops, fixed last commit'\n- run git-rebase -i\n- squash the second commit into the first\n- when prompted for the log message for the combined change,\n  delete the \"Whoops, fixed last commit\" line but leave the first line\n\nThat will accidentally lose the first log message, assuming commentChar=#.\ngit-rebase -i should be a bit friendlier and not bring up an editing window\nwhere the log message ends up being one of the comments.\n\nI suggested it could munge the message with an extra space character, but I\nagree that is a bit unpleasant.  Perhaps better would be\n\n   % git-rebase -i\n   error: commit abcde has log message beginning with '#', which is the\n          current setting of commentChar.  This means that the interactive\n          editing of the log message will not work.  Please set commentChar\n          to some other value (such as 'auto') in your git configuration\n          to be able to rebase interactively.\n\nThe current behaviour is a bit of a trap for the unwary, and anyway it leaves\nno way to specify keeping the existing log message (which begins #).\n\n-- \nEd Avis <eda@waniasset.com>\n"},{"id":"266951","messageId":"vpq3808p40o.fsf@anie.imag.fr","threadId":"39941","inReplyTo":"xmqqr3nsfdmw.fsf@gitster.dls.corp.google.com","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-07-28T17:48:23Z","receivedAt":"2015-07-28T17:48:23Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> Actually, is there any reason why we do not allow a simple escaping like\n>>\n>> \\# this is a line starting with #\n>> \\\\ this is a line starting with \\\n>> # this is a comment\n>\n> What are we trying to achieve?\n\nWhat I would like would be a simple way to:\n\n1) Allow any commit message to be typed. If I want to talk about #include\n   in my commit message, I should have an easy way to do so.\n\n2) Allow commands that pop an editor on an existing message to preserve\n   the original message, whatever it is. Well, actually Git even strips\n   # lines even if it doesn't pop the editor.\n\nCurrently, I can for example:\n\n$ git commit -m \"#include\" -a\n[detached HEAD 0f36ec9] #include\n 1 file changed, 1 insertion(+), 1 deletion(-)\n$ GIT_EDITOR=touch git commit --amend\nAborting commit due to empty commit message.\n\nA simple escaping scheme like the above can solve both points:\n\n1) If I want to talk about #include in my commit message, I can spell it\n   \\#include and Git would remove the \\. The same way, if I want to tell\n   my shell about a \" inside a string, I can write \"double-quote:\\\".\"\n   and get a litteral double-quote.\n\n2) A command that pops an editor could add the escaping where needed,\n   pop the editor, and then unescape. A command like \"pick\" in \"rebase\n   -i\" could escape the message, and feed it to \"git commit\" which would\n   unescape it.\n\n> Munging the original \"# I want this line intact\" to any other form\n> like \" # I want this...\" is as bad as losing it.\n\nIt would modify it only when shown in the text editor. The object\ndatabase would contain unescaped message, hence \"git log\" would show it\nunescaped for example.\n\nbackslash-escaping special characters seems very natural to me, and I\nguess it would be for most computer-scientists. If I have problem with a\nspecial character, the first thing I would try would be to add a\nbackslash in front of it.\n\n> If the user wants whatever she types in the resulting commit\n> literally, there is the \"--cleanup=<choice>\" option, no?\n\n$ GIT_EDITOR=touch git commit --cleanup=verbatim\n[detached HEAD 1b136a7] # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want \nto. # An empty message aborts the commit. # HEAD detached from 5e70007 # Changes to be committed: #     modified:   foo.txt # # Changes not staged for commit\n: #     modified:   foo.txt # # Untracked files: #      last-synchro.txt #                                                                                  \n 1 file changed, 1 insertion(+), 1 deletion(-)\n\nYou really don't want that in day-to-day use.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"266964","messageId":"xmqqtwsodsw0.fsf@gitster.dls.corp.google.com","threadId":"39941","inReplyTo":"vpq3808p40o.fsf@anie.imag.fr","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-28T18:44:15Z","receivedAt":"2015-07-28T18:44:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> A simple escaping scheme like the above can solve both points:\n>\n> 1) If I want to talk about #include in my commit message, I can spell it\n>    \\#include and Git would remove the \\. The same way, if I want to tell\n>    my shell about a \" inside a string, I can write \"double-quote:\\\".\"\n>    and get a litteral double-quote.\n>\n> 2) A command that pops an editor could add the escaping where needed,\n>    pop the editor, and then unescape. A command like \"pick\" in \"rebase\n>    -i\" could escape the message, and feed it to \"git commit\" which would\n>    unescape it.\n> ...\n> backslash-escaping special characters seems very natural to me,...\n\nOK.  So the proposal on the table is that a backslash at the\nbeginning of a line is stripped.\n\nStripping part should look like this.  To make it work for things\nlike \"git commit --amend\", you would need to prefix any line that\ncomes from the payload that begins with the core.commentchar or a\nbackslash with a backslash.\n\ndiff --git a/builtin/stripspace.c b/builtin/stripspace.c\nindex 1259ed7..39ecb92 100644\n--- a/builtin/stripspace.c\n+++ b/builtin/stripspace.c\n@@ -52,6 +52,11 @@ void stripspace(struct strbuf *sb, int skip_comments)\n \t\t}\n \t\tnewlen = cleanup(sb->buf + i, len);\n \n+\t\tif (newlen && sb->buf[i] == '\\\\') {\n+\t\t\ti++;\n+\t\t\tnewlen--;\n+\t\t}\n+\n \t\t/* Not just an empty line? */\n \t\tif (newlen) {\n \t\t\tif (empties > 0 && j > 0)\n"},{"id":"267039","messageId":"vpqk2tjl12j.fsf@anie.imag.fr","threadId":"39941","inReplyTo":"xmqqtwsodsw0.fsf@gitster.dls.corp.google.com","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-07-29T10:17:56Z","receivedAt":"2015-07-29T10:17:56Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> OK.  So the proposal on the table is that a backslash at the\n> beginning of a line is stripped.\n\nYes.\n\n> Stripping part should look like this.\n\nThanks.\n\n> To make it work for things like \"git commit --amend\", you would need\n> to prefix any line that comes from the payload that begins with the\n> core.commentchar or a backslash with a backslash.\n\nThat's it, probably the hardest part. No Git time budget for now, but\nI'm adding this here in case I get time or a student to work on it:\nhttp://git.wiki.kernel.org/index.php/SmallProjectsIdeas\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"267040","messageId":"loom.20150729T121912-670@post.gmane.org","threadId":"39941","inReplyTo":"vpqk2tjl12j.fsf@anie.imag.fr","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Ed Avis","fromEmail":"eda@waniasset.com","sentAt":"2015-07-29T10:19:27Z","receivedAt":"2015-07-29T10:19:27Z","isPatch":false,"sender":{"key":"eda@waniasset.com","avatar":null},"body":"Thank you for looking into this.\n\n-- \nEd Avis <eda@waniasset.com>\n"},{"id":"267042","messageId":"CACsJy8ABsHBA1TubB+6fypT0LGQF_O+CmHPqL+C7nMVjjWy38w@mail.gmail.com","threadId":"39941","inReplyTo":"vpq3808p40o.fsf@anie.imag.fr","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-07-29T10:47:19Z","receivedAt":"2015-07-29T10:47:19Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Jul 29, 2015 at 12:48 AM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n>> If the user wants whatever she types in the resulting commit\n>> literally, there is the \"--cleanup=<choice>\" option, no?\n>\n> $ GIT_EDITOR=touch git commit --cleanup=verbatim\n> [detached HEAD 1b136a7] # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want\n> to. # An empty message aborts the commit. # HEAD detached from 5e70007 # Changes to be committed: #     modified:   foo.txt # # Changes not staged for commit\n> : #     modified:   foo.txt # # Untracked files: #      last-synchro.txt #\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> You really don't want that in day-to-day use.\n\nHow about --cleanup=scissors? The chance that you have the same cut\nline in your commit message is really low, compared to having comment\ncharacters.\n-- \nDuy\n"},{"id":"267044","messageId":"vpq8u9zjgzl.fsf@anie.imag.fr","threadId":"39941","inReplyTo":"CACsJy8ABsHBA1TubB+6fypT0LGQF_O+CmHPqL+C7nMVjjWy38w@mail.gmail.com","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-07-29T12:17:02Z","receivedAt":"2015-07-29T12:17:02Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Wed, Jul 29, 2015 at 12:48 AM, Matthieu Moy\n> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>>> If the user wants whatever she types in the resulting commit\n>>> literally, there is the \"--cleanup=<choice>\" option, no?\n>>\n>> $ GIT_EDITOR=touch git commit --cleanup=verbatim\n>> [detached HEAD 1b136a7] # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want\n>> to. # An empty message aborts the commit. # HEAD detached from 5e70007 # Changes to be committed: #     modified:   foo.txt # # Changes not staged for commit\n>> : #     modified:   foo.txt # # Untracked files: #      last-synchro.txt #\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> You really don't want that in day-to-day use.\n>\n> How about --cleanup=scissors?\n\nI can read this in two different ways:\n\n1) Keeping git as-is and suggest users to use --cleanup=scissors\n\n   This has the same problem as --cleanup=verbatim: it doesn't work as-is\n   since Git doesn't insert the scissors. You can hack around it by\n   adding them by yourself when you need it, but it's really not\n   convenient. You have to anticipate that you're going to require a #\n   and call commit with --cleanup=scissors, add the scissors. And repeat\n   it if you need to \"commit --amend\".\n\n2) Modify Git to add scissors by default, and use --cleanup=scissors by\n   default.\n \n   This is actually more or less what SVN does: it inserts a line\n   \"--This line, and those below, will be ignored--\", and the equivalent\n   of what Git adds as comments in the template is inserted below this\n   line.\n\nI don't think option 1) is good. The fact that we have the --cleanup=\noption shouldn't serve as an excuse to do nothing. I'd be fine with\noption 2), but I find it much more intrusive than to allow a simple\nbackslash-escaping as I suggest.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"267045","messageId":"CACsJy8A-cyXvFoK8HrubVnP9fP47oW_zJ9j5fLurEFB=2cLBrQ@mail.gmail.com","threadId":"39941","inReplyTo":"vpq8u9zjgzl.fsf@anie.imag.fr","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-07-29T12:47:50Z","receivedAt":"2015-07-29T12:47:50Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Jul 29, 2015 at 7:17 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n>> On Wed, Jul 29, 2015 at 12:48 AM, Matthieu Moy\n>> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>>>> If the user wants whatever she types in the resulting commit\n>>>> literally, there is the \"--cleanup=<choice>\" option, no?\n>>>\n>>> $ GIT_EDITOR=touch git commit --cleanup=verbatim\n>>> [detached HEAD 1b136a7] # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want\n>>> to. # An empty message aborts the commit. # HEAD detached from 5e70007 # Changes to be committed: #     modified:   foo.txt # # Changes not staged for commit\n>>> : #     modified:   foo.txt # # Untracked files: #      last-synchro.txt #\n>>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>>\n>>> You really don't want that in day-to-day use.\n>>\n>> How about --cleanup=scissors?\n>\n> I can read this in two different ways:\n>\n> 1) Keeping git as-is and suggest users to use --cleanup=scissors\n>\n>    This has the same problem as --cleanup=verbatim: it doesn't work as-is\n>    since Git doesn't insert the scissors. You can hack around it by\n>    adding them by yourself when you need it, but it's really not\n>    convenient. You have to anticipate that you're going to require a #\n>    and call commit with --cleanup=scissors, add the scissors. And repeat\n>    it if you need to \"commit --amend\".\n>\n> 2) Modify Git to add scissors by default, and use --cleanup=scissors by\n>    default.\n>\n>    This is actually more or less what SVN does: it inserts a line\n>    \"--This line, and those below, will be ignored--\", and the equivalent\n>    of what Git adds as comments in the template is inserted below this\n>    line.\n>\n> I don't think option 1) is good. The fact that we have the --cleanup=\n> option shouldn't serve as an excuse to do nothing. I'd be fine with\n> option 2), but I find it much more intrusive than to allow a simple\n> backslash-escaping as I suggest.\n\nauto backslashing could cause some annoyance. Emacs supports\nrearranging a paragraph to fit in a fixed text column. This generated\nbackslash may be moved around, no longer at the beginning of the line,\nand it will remain in the commit message. I don't know how popular\nthis feature is outside emacs.\n\nHaving said that, even scissors has its own (and probably bigger)\nproblem: when you commit after conflict resolution, git inserts a\n\"Conflicts:\" paragraph, prepended by core.commentChar. With default\nsettings, it serves as a reminder, but will be automatically stripped.\nWith scissors, it stays by default because it's placed before the\nscissor line.\n-- \nDuy\n"},{"id":"267060","messageId":"xmqqvbd39cxj.fsf@gitster.dls.corp.google.com","threadId":"39941","inReplyTo":"vpq8u9zjgzl.fsf@anie.imag.fr","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-29T15:54:48Z","receivedAt":"2015-07-29T15:54:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n>> On Wed, Jul 29, 2015 at 12:48 AM, Matthieu Moy\n>> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>>>> If the user wants whatever she types in the resulting commit\n>>>> literally, there is the \"--cleanup=<choice>\" option, no?\n>>>\n>>> $ GIT_EDITOR=touch git commit --cleanup=verbatim\n>>> [detached HEAD 1b136a7] # Please enter the commit message for your\n>>> changes. Lines starting # with '#' will be kept; you may remove\n>>> them yourself if you want\n>>> to. # An empty message aborts the commit. # HEAD detached from\n>>> 5e70007 # Changes to be committed: # modified: foo.txt # # Changes\n>>> not staged for commit\n>>> : #     modified:   foo.txt # # Untracked files: #      last-synchro.txt #\n>>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>>\n>>> You really don't want that in day-to-day use.\n\nI do not quite follow this example.\n\nThe user said \"I'll be responsible for cleaning up\" by giving the\noption.  It is up to the user to use an editor that is something a\nbit more intelligent than \"touch\" to remove the instructional\ncomments meant for humans after reading them.\n\n> 2) Modify Git to add scissors by default, and use --cleanup=scissors by\n>    default.\n\nI just did \"$ git commit --amend --cleanup=scissors\" (with and\nwithout --amend) and it seems to do exactly that ;-).\n"},{"id":"267064","messageId":"vpqmvyfeysc.fsf@anie.imag.fr","threadId":"39941","inReplyTo":"xmqqvbd39cxj.fsf@gitster.dls.corp.google.com","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-07-29T16:03:47Z","receivedAt":"2015-07-29T16:03:47Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n>\n>> Duy Nguyen <pclouds@gmail.com> writes:\n>>\n>>> On Wed, Jul 29, 2015 at 12:48 AM, Matthieu Moy\n>>> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>>>>> If the user wants whatever she types in the resulting commit\n>>>>> literally, there is the \"--cleanup=<choice>\" option, no?\n>>>>\n>>>> $ GIT_EDITOR=touch git commit --cleanup=verbatim\n>>>> [detached HEAD 1b136a7] # Please enter the commit message for your\n>>>> changes. Lines starting # with '#' will be kept; you may remove\n>>>> them yourself if you want\n>>>> to. # An empty message aborts the commit. # HEAD detached from\n>>>> 5e70007 # Changes to be committed: # modified: foo.txt # # Changes\n>>>> not staged for commit\n>>>> : #     modified:   foo.txt # # Untracked files: #      last-synchro.txt #\n>>>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>>>\n>>>> You really don't want that in day-to-day use.\n>\n> I do not quite follow this example.\n>\n> The user said \"I'll be responsible for cleaning up\" by giving the\n> option.  It is up to the user to use an editor that is something a\n> bit more intelligent than \"touch\" to remove the instructional\n> comments meant for humans after reading them.\n\nYes, --cleanup=verbatim does what it says it does. Now, my claim is that\nit does not answer the use-case \"I want an easy way to talk about # in a\ncommit message\". First, you have to specify --cleanup=verbatim _before_\ntyping the message, hence before knowing that you may need a #.\n\nThen, as you say, it is up to the user to remove things that Git has\nadded. Why would we ask the user to do this when we have a way to have\nthe tool do it?\n\n>> 2) Modify Git to add scissors by default, and use --cleanup=scissors by\n>>    default.\n>\n> I just did \"$ git commit --amend --cleanup=scissors\" (with and\n> without --amend) and it seems to do exactly that ;-).\n\nAh, I did my test in the same repo I messed-up with --cleanup=verbatim.\nIt's better than I thought then. So a viable alternative to the\nbackslas-escaping would be to change commit.cleanup to scissors by\ndefault.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"267073","messageId":"xmqqegjqaodd.fsf@gitster.dls.corp.google.com","threadId":"39941","inReplyTo":"vpqmvyfeysc.fsf@anie.imag.fr","subject":"Re: Log messages beginning # and git rebase -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-29T17:02:22Z","receivedAt":"2015-07-29T17:02:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Then, as you say, it is up to the user to remove things that Git has\n> added. Why would we ask the user to do this when we have a way to have\n> the tool do it?\n\nThe timeline of development, perhaps?  I thought cleanup=scissors was\na fairly recent invention that hasn't been used widely yet.\n"},{"id":"374235","messageId":"20190422100539.2446-1-corentin.bompard@etu.univ-lyon1.fr","threadId":"39941","inReplyTo":"xmqqtwsodsw0.fsf@gitster.dls.corp.google.com","subject":"[PATCH] allow commentChars in commit messages","fromName":"Corentin BOMPARD","fromEmail":"corentin.bompard@etu.univ-lyon1.fr","sentAt":"2019-04-22T10:05:39Z","receivedAt":"2019-04-22T10:06:20Z","isPatch":true,"sender":{"key":"corentin.bompard@etu.univ-lyon1.fr","avatar":"https://avatars.githubusercontent.com/u/23448477?v=4"},"body":"From: Corentin Bompard <corentin.bompard@etu.univ-lyon1.fr>\n\nAdd new argument which permits stripspace to escape backslashes\nin order to have commit messages which begins with commentChars\nand backslashes.\n\nAdd new function strbuf_addbackslash which adds a backslash before\ncommentChars and other backslashes used by git commit --amend\nwhich prevents escaping the commit message lines which starts with\na commentChar.\n\nSigned-off-by: Corentin BOMPARD <corentin.bompard@etu.univ-lyon1.fr>\nSigned-off-by: Nathan BERBEZIER <nathan.berbezier@etu.univ-lyon1.fr>\nSigned-off-by: Pablo CHABANNE <pablo.chabanne@etu.univ-lyon1.fr>\nSigned-off-by: Matthieu MOY <matthieu.moy@univ-lyon1.fr>\n---\n \n builtin/am.c                       |  2 +-\n builtin/branch.c                   |  2 +-\n builtin/commit.c                   |  8 ++-\n builtin/merge.c                    |  2 +-\n builtin/notes.c                    |  6 +-\n builtin/stripspace.c               |  2 +-\n builtin/tag.c                      |  2 +-\n rebase-interactive.c               |  2 +-\n sequencer.c                        |  6 +-\n strbuf.c                           | 64 +++++++++++++++++++-\n strbuf.h                           |  8 ++-\n t/t7526-commit-message-comments.sh | 93 ++++++++++++++++++++++++++++++\n 12 files changed, 180 insertions(+), 17 deletions(-)\n create mode 100755 t/t7526-commit-message-comments.sh\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex 58a2aef28..58817ab90 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -1212,7 +1212,7 @@ static int parse_mail(struct am_state *state, const char *mail)\n \n \tstrbuf_addstr(&msg, \"\\n\\n\");\n \tstrbuf_addbuf(&msg, &mi.log_message);\n-\tstrbuf_stripspace(&msg, 0);\n+\tstrbuf_stripspace(&msg, 0, 0);\n \n \tassert(!state->author_name);\n \tstate->author_name = strbuf_detach(&author_name, NULL);\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 1be727209..0bfb17fc3 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -568,7 +568,7 @@ static int edit_branch_description(const char *branch_name)\n \t\tstrbuf_release(&buf);\n \t\treturn -1;\n \t}\n-\tstrbuf_stripspace(&buf, 1);\n+\tstrbuf_stripspace(&buf, 1, 0);\n \n \tstrbuf_addf(&name, \"branch.%s.description\", branch_name);\n \tgit_config_set(name.buf, buf.len ? buf.buf : NULL);\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 2986553d5..49075a7ac 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -710,8 +710,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \t} else if (use_message) {\n \t\tchar *buffer;\n \t\tbuffer = strstr(use_message_buffer, \"\\n\\n\");\n-\t\tif (buffer)\n+\t\tif (buffer) {\n \t\t\tstrbuf_addstr(&sb, skip_blank_lines(buffer + 2));\n+\t\t\tstrbuf_addbackslash(&sb);\n+\t\t}\n \t\thook_arg1 = \"commit\";\n \t\thook_arg2 = use_message;\n \t} else if (fixup_message) {\n@@ -786,7 +788,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,\n \ts->hints = 0;\n \n \tif (clean_message_contents)\n-\t\tstrbuf_stripspace(&sb, 0);\n+\t\tstrbuf_stripspace(&sb, 0, 0);\n \n \tif (signoff)\n \t\tappend_signoff(&sb, ignore_non_trailer(sb.buf, sb.len), 0);\n@@ -1621,7 +1623,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \t    cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)\n \t\tstrbuf_setlen(&sb, wt_status_locate_end(sb.buf, sb.len));\n \tif (cleanup_mode != COMMIT_MSG_CLEANUP_NONE)\n-\t\tstrbuf_stripspace(&sb, cleanup_mode == COMMIT_MSG_CLEANUP_ALL);\n+\t\tstrbuf_stripspace(&sb, cleanup_mode == COMMIT_MSG_CLEANUP_ALL, 1);\n \n \tif (message_is_empty(&sb, cleanup_mode) && !allow_empty_message) {\n \t\trollback_index_files();\ndiff --git a/builtin/merge.c b/builtin/merge.c\nindex e47d77bae..d0c3cb033 100644\n--- a/builtin/merge.c\n+++ b/builtin/merge.c\n@@ -829,7 +829,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)\n \t\tabort_commit(remoteheads, NULL);\n \n \tread_merge_msg(&msg);\n-\tstrbuf_stripspace(&msg, 0 < option_edit);\n+\tstrbuf_stripspace(&msg, 0 < option_edit, 0);\n \tif (!msg.len)\n \t\tabort_commit(remoteheads, _(\"Empty commit message.\"));\n \tstrbuf_release(&merge_msg);\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 02e97f55c..fd304ed9c 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -196,7 +196,7 @@ static void prepare_note_data(const struct object_id *object, struct note_data *\n \t\tif (launch_editor(d->edit_path, &d->buf, NULL)) {\n \t\t\tdie(_(\"please supply the note contents using either -m or -F option\"));\n \t\t}\n-\t\tstrbuf_stripspace(&d->buf, 1);\n+\t\tstrbuf_stripspace(&d->buf, 1, 0);\n \t}\n }\n \n@@ -221,7 +221,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)\n \tif (d->buf.len)\n \t\tstrbuf_addch(&d->buf, '\\n');\n \tstrbuf_addstr(&d->buf, arg);\n-\tstrbuf_stripspace(&d->buf, 0);\n+\tstrbuf_stripspace(&d->buf, 0, 0);\n \n \td->given = 1;\n \treturn 0;\n@@ -240,7 +240,7 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)\n \t\t\tdie_errno(_(\"cannot read '%s'\"), arg);\n \t} else if (strbuf_read_file(&d->buf, arg, 1024) < 0)\n \t\tdie_errno(_(\"could not open or read '%s'\"), arg);\n-\tstrbuf_stripspace(&d->buf, 0);\n+\tstrbuf_stripspace(&d->buf, 0, 0);\n \n \td->given = 1;\n \treturn 0;\ndiff --git a/builtin/stripspace.c b/builtin/stripspace.c\nindex be33eb83c..c5d449b5e 100644\n--- a/builtin/stripspace.c\n+++ b/builtin/stripspace.c\n@@ -55,7 +55,7 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)\n \t\tdie_errno(\"could not read the input\");\n \n \tif (mode == STRIP_DEFAULT || mode == STRIP_COMMENTS)\n-\t\tstrbuf_stripspace(&buf, mode == STRIP_COMMENTS);\n+\t\tstrbuf_stripspace(&buf, mode == STRIP_COMMENTS, 0);\n \telse\n \t\tcomment_lines(&buf);\n \ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 02f6bd127..cb9422c17 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -261,7 +261,7 @@ static void create_tag(const struct object_id *object, const char *tag,\n \t}\n \n \tif (opt->cleanup_mode != CLEANUP_NONE)\n-\t\tstrbuf_stripspace(buf, opt->cleanup_mode == CLEANUP_ALL);\n+\t\tstrbuf_stripspace(buf, opt->cleanup_mode == CLEANUP_ALL, 0);\n \n \tif (!opt->message_given && !buf->len)\n \t\tdie(_(\"no tag message?\"));\ndiff --git a/rebase-interactive.c b/rebase-interactive.c\nindex 68aff1dac..6e6e45c45 100644\n--- a/rebase-interactive.c\n+++ b/rebase-interactive.c\n@@ -61,7 +61,7 @@ int edit_todo_list(struct repository *r, unsigned flags)\n \tif (strbuf_read_file(&buf, todo_file, 0) < 0)\n \t\treturn error_errno(_(\"could not read '%s'.\"), todo_file);\n \n-\tstrbuf_stripspace(&buf, 1);\n+\tstrbuf_stripspace(&buf, 1, 0);\n \tif (write_message(buf.buf, buf.len, todo_file, 0)) {\n \t\tstrbuf_release(&buf);\n \t\treturn -1;\ndiff --git a/sequencer.c b/sequencer.c\nindex 0db410d59..231682632 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1041,7 +1041,7 @@ int template_untouched(const struct strbuf *sb, const char *template_file,\n \tif (!template_file || strbuf_read_file(&tmpl, template_file, 0) <= 0)\n \t\treturn 0;\n \n-\tstrbuf_stripspace(&tmpl, cleanup_mode == COMMIT_MSG_CLEANUP_ALL);\n+\tstrbuf_stripspace(&tmpl, cleanup_mode == COMMIT_MSG_CLEANUP_ALL, 0);\n \tif (!skip_prefix(sb->buf, tmpl.buf, &start))\n \t\tstart = sb->buf;\n \tstrbuf_release(&tmpl);\n@@ -1386,7 +1386,7 @@ static int try_to_commit(struct repository *r,\n \t\t\t\t\t  opts->default_msg_cleanup;\n \n \tif (cleanup != COMMIT_MSG_CLEANUP_NONE)\n-\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL);\n+\t\tstrbuf_stripspace(msg, cleanup == COMMIT_MSG_CLEANUP_ALL, 0);\n \tif ((flags & EDIT_MSG) && message_is_empty(msg, cleanup)) {\n \t\tres = 1; /* run 'git commit' to display error message */\n \t\tgoto out;\n@@ -4941,7 +4941,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla\n \t\treturn -1;\n \t}\n \n-\tstrbuf_stripspace(buf, 1);\n+\tstrbuf_stripspace(buf, 1, 0);\n \tif (buf->len == 0) {\n \t\tapply_autostash(opts);\n \t\tsequencer_remove_state(opts);\ndiff --git a/strbuf.c b/strbuf.c\nindex f6a6cf78b..148ba2815 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -966,8 +966,12 @@ static size_t cleanup(char *line, size_t len)\n  *\n  * Enable skip_comments to skip every line starting with comment\n  * character.\n+ *\n+ * Enable escape_backslash to remove backslash in beginning of\n+ * lines.\n  */\n-void strbuf_stripspace(struct strbuf *sb, int skip_comments)\n+void strbuf_stripspace(struct strbuf *sb, int skip_comments,\n+\t\tint escape_backslash)\n {\n \tsize_t empties = 0;\n \tsize_t i, j, len, newlen;\n@@ -999,8 +1003,66 @@ void strbuf_stripspace(struct strbuf *sb, int skip_comments)\n \t}\n \n \tstrbuf_setlen(sb, j);\n+\n+\tif (escape_backslash) {\n+\t\tstrbuf_escape_backslash(sb);\n+\t}\n+}\n+\n+/*\n+ * Add a backslash in front of commentChar and other backslash.\n+ */\n+void strbuf_addbackslash(struct strbuf *sb)\n+{\n+\tsize_t i, len = 0, total = 0;\n+\tchar *eol;\n+\n+\tfor (i = 0; i < sb->len; i += len) {\n+\t\teol = memchr(sb->buf + i, '\\n', sb->len -i);\n+\t\tlen = eol ? eol - (sb->buf + i) + 1 : sb->len - i;\n+\n+\t\tif (len > 0 && sb->buf[i] == comment_line_char) {\n+\t\t\tmemmove(sb->buf + i + 1, sb->buf + i, sb->len - i);\n+\t\t\tsb->buf[i] = '\\\\';\n+\t\t\ttotal += (len + 1);\n+\t\t} else if (len > 0 && sb->buf[i] == '\\\\') {\n+\t\t\tmemmove(sb->buf + i + 1, sb->buf + i, sb->len - i);\n+\t\t\tsb->buf[i] = '\\\\';\n+\t\t\ttotal += len;\n+\t\t} else {\n+\t\t\ttotal += len;\n+\t\t}\n+\t}\n+\tstrbuf_grow(sb, total-len);\n+\tstrbuf_setlen(sb, total);\n }\n \n+/*\n+ * Escape backslash in beginning of lines.\n+ */\n+void strbuf_escape_backslash(struct strbuf *sb)\n+{\n+\tsize_t i, len, total = sb->len;\n+\tchar *eol;\n+\n+\tfor (i = 0; i < sb->len; i += len) {\n+\t\teol = memchr(sb->buf + i, '\\n', sb->len - i);\n+\t\tlen = eol ? eol - (sb->buf + i) + 1 : sb->len - i;\n+\n+\t\tif (sb->buf[i] == '\\\\') {\n+\t\t\tmemmove(sb->buf + i, sb->buf + i + 1, total - 1 - i);\n+\t\t\ttotal --;\n+\t\t\tlen --;\n+\t\t\ti++;\n+\t\t}\n+\t\t/* Avoid initite loop if len=0 */\n+\t\tif (len <= 0) len = 1;\n+\t}\n+\tstrbuf_setlen(sb, sb->len - (sb->len - total));\n+}\n+\n+\n+\n int strbuf_normalize_path(struct strbuf *src)\n {\n \tstruct strbuf dst = STRBUF_INIT;\ndiff --git a/strbuf.h b/strbuf.h\nindex fc40873b6..6ee958498 100644\n--- a/strbuf.h\n+++ b/strbuf.h\n@@ -499,8 +499,14 @@ int strbuf_normalize_path(struct strbuf *sb);\n /**\n  * Strip whitespace from a buffer. The second parameter controls if\n  * comments are considered contents to be removed or not.\n+ * The third parameter controls if backslashes are escaped.\n  */\n-void strbuf_stripspace(struct strbuf *buf, int skip_comments);\n+void strbuf_stripspace(struct strbuf *buf, int skip_comments,\n+\t\tint escape_backslash);\n+\n+void strbuf_escape_backslash(struct strbuf *sb);\n+\n+void strbuf_addbackslash(struct strbuf *sb);\n \n static inline int strbuf_strip_suffix(struct strbuf *sb, const char *suffix)\n {\ndiff --git a/t/t7526-commit-message-comments.sh b/t/t7526-commit-message-comments.sh\nnew file mode 100755\nindex 000000000..e4b04eb7a\n--- /dev/null\n+++ b/t/t7526-commit-message-comments.sh\n@@ -0,0 +1,93 @@\n+#!/bin/sh\n+\n+test_description='\"git commit\" allows # in the start of a line in commit message.\n+\n+'\n+. ./test-lib.sh\n+\n+\n+# set up fake editor for interactive editing\n+cat >fake-editor <<'EOF'\n+#!/bin/sh\n+cp FAKE_MSG \"$1\"\n+exit 0\n+EOF\n+chmod +x fake-editor\n+\n+FAKE_EDITOR=\"$(pwd)/fake-editor\"\n+export FAKE_EDITOR\n+\n+commit_msg_is () {\n+\ttest \"$(git log --pretty=format:%s%b -1)\" = \"$1\"\n+}\n+\n+ensure_fresh_upstream () {\n+\trm -rf parent && git init --bare parent\n+}\n+\n+test_expect_success 'setup bare parent' '\n+\tensure_fresh_upstream &&\n+\tgit remote add upstream parent\n+'\n+\n+test_expect_success 'git commit \"\\#text\" keeps \"#text\" as a commit message' '\n+\techo test1 >file &&\n+\tgit add file &&\n+\tprintf \"%s\\n\" \"\\\\#text\" >FAKE_MSG &&\n+\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit &&\n+\tcommit_msg_is \"#text\"\n+'\n+\n+test_expect_success 'git commit \"\\text\" keeps \"text\" as a commit message' '\n+\techo test2 >file &&\n+\tgit add file &&\n+\tprintf \"%s\\n\" \"\\\\text\" >FAKE_MSG &&\n+\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit &&\n+\tcommit_msg_is \"text\"\n+'\n+\n+test_expect_success 'git commit \"\\\\text\" keeps \"\\text\" as a commit message' '\n+\techo test5 >file &&\n+\tgit add file &&\n+\tprintf \"%s\\n\" \"\\\\\\\\text\" >FAKE_MSG &&\n+\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit &&\n+\tcommit_msg_is \"\\\\text\"\n+'\n+\n+test_expect_success 'git commit -m \"\\#text\" keeps \"#text\" as a commit message' '\n+\techo test1 >file &&\n+\tgit add file &&\n+\tgit commit -m \"\\\\#text\" &&\n+\tcommit_msg_is \"#text\"\n+'\n+\n+test_expect_success 'git commit -m \"\\text\" keeps \"text\" as a commit message' '\n+\techo test2 >file &&\n+\tgit add file &&\n+\tgit commit -m \"\\\\text\" &&\n+\tcommit_msg_is \"text\"\n+'\n+\n+test_expect_success 'git commit -m \"\\\\text\" keeps \"\\text\" as a commit message' '\n+\techo test3 >file &&\n+\tgit add file &&\n+\tgit commit -m \"\\\\\\\\text\" &&\n+\tcommit_msg_is \"\\\\text\"\n+'\n+\n+test_expect_success 'git commit --amend add backslash in front of comment\n+and other backslash' '\n+\techo \"\\\\#Include something\" > msg &&\n+\techo \"\" >> msg &&\n+\techo \"Some content\" >> msg &&\n+\techo \"\\\\\\\\\\\\Backslash example\" >> msg &&\n+\techo \"test amend\" > file &&\n+\tgit add file &&\n+\tgit commit -F msg &&\n+\tcat .git/COMMIT_EDITMSG > expect &&\n+\tgit commit --amend &&\n+\tsed \"/^#/d\" .git/COMMIT_EDITMSG > actual &&\n+\tsed -i -e \"$ d\" actual &&\n+\ttest_cmp expect actual\n+'\n+test_done\n-- \n2.21.0-rc0\n\n"}]}