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

Re: Log messages beginning # and git rebase -i

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jul 28, 2015, 17:48 UTC
Message-ID
<vpq3808p40o.fsf@anie.imag.fr>
In-Reply-To
<xmqqr3nsfdmw.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> Actually, is there any reason why we do not allow a simple escaping like
>>
>> \# this is a line starting with #
>> \\ this is a line starting with \
>> # this is a comment
>
> What are we trying to achieve?
What I would like would be a simple way to:
1) Allow any commit message to be typed. If I want to talk about #include
   in my commit message, I should have an easy way to do so.
2) Allow commands that pop an editor on an existing message to preserve
   the original message, whatever it is. Well, actually Git even strips
   # lines even if it doesn't pop the editor.
Currently, I can for example:
$ git commit -m "#include" -a
[detached HEAD 0f36ec9] #include
 1 file changed, 1 insertion(+), 1 deletion(-)
$ GIT_EDITOR=touch git commit --amend
Aborting commit due to empty commit message.
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.
> Munging the original "# I want this line intact" to any other form
> like " # I want this..." is as bad as losing it.

It would modify it only when shown in the text editor. The object database would contain unescaped message, hence "git log" would show it unescaped for example.

backslash-escaping special characters seems very natural to me, and I guess it would be for most computer-scientists. If I have problem with a special character, the first thing I would try would be to add a backslash in front of it.

> If the user wants whatever she types in the resulting commit
> literally, there is the "--cleanup=<choice>" option, no?
$ GIT_EDITOR=touch git commit --cleanup=verbatim
[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 
to. # An empty message aborts the commit. # HEAD detached from 5e70007 # Changes to be committed: #     modified:   foo.txt # # Changes not staged for commit
: #     modified:   foo.txt # # Untracked files: #      last-synchro.txt #                                                                                  
 1 file changed, 1 insertion(+), 1 deletion(-)
You really don't want that in day-to-day use.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Ed AvisNext: Junio C Hamano
Message 8 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.