git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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)
Previous: Matthieu MoyNext: Matthieu Moy
Message 9 of 18 in “Log messages beginning # and git rebase -i”
  1. Ed AvisJul 27, 2015
  2. Eric SunshineJul 27, 2015
  3. Duy NguyenJul 28, 2015
  4. Ed AvisJul 28, 2015
  5. Matthieu MoyJul 28, 2015
  6. Junio C HamanoJul 28, 2015
  7. Ed AvisJul 28, 2015
  8. Matthieu MoyJul 28, 2015
  9. Junio C HamanoJul 28, 2015
  10. Matthieu MoyJul 29, 2015
  11. Ed AvisJul 29, 2015
  12. allow commentChars in commit messagesCorentin BOMPARD, Apr 22, 2019
  13. Duy NguyenJul 29, 2015
  14. Matthieu MoyJul 29, 2015
  15. Duy NguyenJul 29, 2015
  16. Junio C HamanoJul 29, 2015
  17. Matthieu MoyJul 29, 2015
  18. Junio C HamanoJul 29, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.