Re: Log messages beginning # and git rebase -i
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 28, 2015, 18:44 UTC
- Message-ID
- <xmqqtwsodsw0.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <vpq3808p40o.fsf@anie.imag.fr>
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 13 quoted lines
> A simple escaping scheme like the above can solve both points: > > 1) If I want to talk about #include in my commit message, I can spell it > \#include and Git would remove the \. The same way, if I want to tell > my shell about a " inside a string, I can write "double-quote:\"." > and get a litteral double-quote. > > 2) A command that pops an editor could add the escaping where needed, > pop the editor, and then unescape. A command like "pick" in "rebase > -i" could escape the message, and feed it to "git commit" which would > unescape it. > ... > backslash-escaping special characters seems very natural to me,...
OK. So the proposal on the table is that a backslash at the beginning of a line is stripped.
Stripping part should look like this. To make it work for things like "git commit --amend", you would need to prefix any line that comes from the payload that begins with the core.commentchar or a backslash with a backslash.
diff --git a/builtin/stripspace.c b/builtin/stripspace.c index 1259ed7..39ecb92 100644 --- a/builtin/stripspace.c +++ b/builtin/stripspace.c @@ -52,6 +52,11 @@ void stripspace(struct strbuf *sb, int skip_comments) } newlen = cleanup(sb->buf + i, len); + if (newlen && sb->buf[i] == '\\') { + i++; + newlen--; + } + /* Not just an empty line? */ if (newlen) { if (empties > 0 && j > 0)