Log messages beginning # and git rebase -i
git commit will happily let you specify log messages beginning with #. But then on git rebase -i, when squashing some commits, the editing for the combined log message treats lines beginning with # as comments. This means that if you are not careful the commit message can get lost on rebasing.
I suggest that git rebase should add an extra space at the start of existing log message lines which begin with #. That is a bit of a kludge but it is better than losing them because they got mixed up with comments.
Signature · 1 line
Ed Avis <[email protected]>
Quoted 8 lines · Ed Avis
git commit will happily let you specify log messages beginning with #. But then on git rebase -i, when squashing some commits, the editing for the combined log message treats lines beginning with # as comments. This means that if you are not careful the commit message can get lost on rebasing.
I suggest that git rebase should add an extra space at the start of existing log message lines which begin with #. That is a bit of a kludge but it is better than losing them because they got mixed up with comments.
'git rebase --interactive' respects the core.commentChar configuration variable, which you can set to some value other than '#'.
Quoted 6 lines · Eric Sunshine
Quoted 5 lines · Ed Avis
git commit will happily let you specify log messages beginning with #. But then on git rebase -i, when squashing some commits, the editing for the combined log message treats lines beginning with # as comments. This means that if you are not careful the commit message can get lost on rebasing.
Quoted 6 lines
Quoted 3 lines
I suggest that git rebase should add an extra space at the start of existing log message lines which begin with #. That is a bit of a kludge but it is better than losing them because they got mixed up with comments.
'git rebase --interactive' respects the core.commentChar configuration variable, which you can set to some value other than '#'.
Yeah. I recommend setting it to 'auto' so it will pick an unused character as separator (most of the time, don't push it too hard)
Signature · 1 line
Duy
Quoted 8 lines · Eric Sunshine <sunshine <at> sunshineco.com> writes:
Quoted 5 lines
the editing for the
combined log message treats lines beginning with # as comments. This means that if you are not careful the commit message can get lost on rebasing.I suggest that git rebase should add an extra space at the start
'git rebase --interactive' respects the core.commentChar configuration variable, which you can set to some value other than '#'.
I was thinking of the default configuration. But you are right, this applies to whatever the comment character is - so if commentChar is set to * for example, then log lines beginning with * should get an extra space prepended in git rebase --interactive so that they don't get lost.
Signature · 1 line
Ed Avis <[email protected]>
Quoted 8 lines · Ed Avis
Quoted 5 lines · Eric Sunshine <sunshine <at> sunshineco.com> writes:
Quoted 5 lines
the editing for the
combined log message treats lines beginning with # as comments. This means that if you are not careful the commit message can get lost on rebasing.I suggest that git rebase should add an extra space at the start
Quoted 7 lines
Quoted 2 lines
'git rebase --interactive' respects the core.commentChar configuration variable, which you can set to some value other than '#'.
I was thinking of the default configuration. But you are right, this applies to whatever the comment character is - so if commentChar is set to * for example, then log lines beginning with * should get an extra space prepended in git rebase --interactive so that they don't get lost.
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
?
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 18 lines · Matthieu Moy
Quoted 8 lines · Ed Avis
Quoted 5 lines · Eric Sunshine <sunshine <at> sunshineco.com> writes:
Quoted 5 lines
the editing for the
combined log message treats lines beginning with # as comments. This means that if you are not careful the commit message can get lost on rebasing.I suggest that git rebase should add an extra space at the start
Quoted 7 lines
Quoted 2 lines
'git rebase --interactive' respects the core.commentChar configuration variable, which you can set to some value other than '#'.
I was thinking of the default configuration. But you are right, this applies to whatever the comment character is - so if commentChar is set to * for example, then log lines beginning with * should get an extra space prepended in git rebase --interactive so that they don't get lost.
Quoted 5 lines
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?
Munging the original "# I want this line intact" to any other form like " # I want this..." is as bad as losing it. If the user wants whatever she types in the resulting commit literally, there is the "--cleanup=<choice>" option, no?
I was considering this case:
- git commit -a '-m# characters are now handled OK'
- hack, hack
- git commit -a '-mWhoops, fixed last commit'
- run git-rebase -i
- squash the second commit into the first
- when prompted for the log message for the combined change, delete the "Whoops, fixed last commit" line but leave the first line
That will accidentally lose the first log message, assuming commentChar=#. git-rebase -i should be a bit friendlier and not bring up an editing window where the log message ends up being one of the comments.
I suggested it could munge the message with an extra space character, but I agree that is a bit unpleasant. Perhaps better would be
% git-rebase -i
error: commit abcde has log message beginning with '#', which is the
current setting of commentChar. This means that the interactive editing of the log message will not work. Please set commentChar to some other value (such as 'auto') in your git configuration to be able to rebase interactively.
The current behaviour is a bit of a trap for the unwary, and anyway it leaves no way to specify keeping the existing log message (which begins #).
Signature · 1 line
Ed Avis <[email protected]>
Quoted 9 lines · Junio C Hamano
Quoted 5 lines · Matthieu Moy
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 commentWhat 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.
Quoted 2 lines
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.
Quoted 2 lines
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.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 7 lines · Matthieu Moy
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.
Quoted 6 lines
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.
builtin/stripspace.c +5 -0
@@ -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 )
Quoted 2 lines · Junio C Hamano
OK. So the proposal on the table is that a backslash at the beginning of a line is stripped.
Yes.
Quoted 1 line
Stripping part should look like this.
Thanks.
Quoted 3 lines
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.
That's it, probably the hardest part. No Git time budget for now, but I'm adding this here in case I get time or a student to work on it:
http://git.wiki.kernel.org/index.php/SmallProjectsIdeas
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Thank you for looking into this.
Signature · 1 line
Ed Avis <[email protected]>
PATCH 1/1 allow commentChars in commit messages
In reply to Junio C HamanoFrom: Corentin Bompard <[email protected]>
Add new argument which permits stripspace to escape backslashes in order to have commit messages which begins with commentChars and backslashes.
Add new function strbuf_addbackslash which adds a backslash before commentChars and other backslashes used by git commit --amend which prevents escaping the commit message lines which starts with a commentChar.
---
builtin/am.c | 2 +- builtin/branch.c | 2 +- builtin/commit.c | 8 ++- builtin/merge.c | 2 +- builtin/notes.c | 6 +- builtin/stripspace.c | 2 +- builtin/tag.c | 2 +- rebase-interactive.c | 2 +- sequencer.c | 6 +- strbuf.c | 64 +++++++++++++++++++- strbuf.h | 8 ++- t/t7526-commit-message-comments.sh | 93 ++++++++++++++++++++++++++++++ 12 files changed, 180 insertions(+), 17 deletions(-) create mode 100755 t/t7526-commit-message-comments.sh
builtin/am.c +1 -1
@@ -1212,7 +1212,7 @@ static int parse_mail(struct am_state *state, const char *mail)strbuf_addstr (&msg,"\n\n" );strbuf_addbuf (&msg, &mi.log_message); -strbuf_stripspace (&msg,0 ); +strbuf_stripspace (&msg,0 ,0 );assert (!state->author_name); state->author_name =strbuf_detach (&author_name,NULL );
builtin/branch.c +1 -1
@@ -568,7 +568,7 @@ static int edit_branch_description(const char *branch_name)strbuf_release (&buf);return -1 ; } -strbuf_stripspace (&buf,1 ); +strbuf_stripspace (&buf,1 ,0 );strbuf_addf (&name,"branch.%s.description" , branch_name);git_config_set (name.buf, buf.len ? buf.buf :NULL );
builtin/commit.c +5 -3
@@ -710,8 +710,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix, }else if (use_message) {char *buffer; buffer =strstr (use_message_buffer,"\n\n" ); -if (buffer) +if (buffer) {strbuf_addstr (&sb,skip_blank_lines (buffer +2 )); +strbuf_addbackslash (&sb); + } hook_arg1 ="commit" ; hook_arg2 = use_message; }else if (fixup_message) {
@@ -786,7 +788,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, s->hints =0 ;if (clean_message_contents) -strbuf_stripspace (&sb,0 ); +strbuf_stripspace (&sb,0 ,0 );if (signoff)append_signoff (&sb,ignore_non_trailer (sb.buf, sb.len),0 );
@@ -1621,7 +1623,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS)strbuf_setlen (&sb,wt_status_locate_end (sb.buf, sb.len));if (cleanup_mode !=COMMIT_MSG_CLEANUP_NONE ) -strbuf_stripspace (&sb, cleanup_mode ==COMMIT_MSG_CLEANUP_ALL ); +strbuf_stripspace (&sb, cleanup_mode ==COMMIT_MSG_CLEANUP_ALL ,1 );if (message_is_empty (&sb, cleanup_mode) && !allow_empty_message) {rollback_index_files ();
builtin/merge.c +1 -1
@@ -829,7 +829,7 @@ static void prepare_to_commit(struct commit_list *remoteheads)abort_commit (remoteheads,NULL );read_merge_msg (&msg); -strbuf_stripspace (&msg,0 < option_edit); +strbuf_stripspace (&msg,0 < option_edit,0 );if (!msg.len)abort_commit (remoteheads,_ ("Empty commit message." ));strbuf_release (&merge_msg);
builtin/notes.c +3 -3
@@ -196,7 +196,7 @@ static void prepare_note_data(const struct object_id *object, struct note_data *if (launch_editor (d->edit_path, &d->buf,NULL )) {die (_ ("please supply the note contents using either -m or -F option" )); } -strbuf_stripspace (&d->buf,1 ); +strbuf_stripspace (&d->buf,1 ,0 ); } }
@@ -221,7 +221,7 @@ static int parse_msg_arg(const struct option *opt, const char *arg, int unset)if (d->buf.len)strbuf_addch (&d->buf,'\n' );strbuf_addstr (&d->buf, arg); -strbuf_stripspace (&d->buf,0 ); +strbuf_stripspace (&d->buf,0 ,0 ); d->given =1 ;return 0 ;
@@ -240,7 +240,7 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)die_errno (_ ("cannot read '%s'" ), arg); }else if (strbuf_read_file (&d->buf, arg,1024 ) <0 )die_errno (_ ("could not open or read '%s'" ), arg); -strbuf_stripspace (&d->buf,0 ); +strbuf_stripspace (&d->buf,0 ,0 ); d->given =1 ;return 0 ;
builtin/stripspace.c +1 -1
@@ -55,7 +55,7 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)die_errno ("could not read the input" );if (mode ==STRIP_DEFAULT || mode ==STRIP_COMMENTS ) -strbuf_stripspace (&buf, mode ==STRIP_COMMENTS ); +strbuf_stripspace (&buf, mode ==STRIP_COMMENTS ,0 );else comment_lines (&buf);
builtin/tag.c +1 -1
@@ -261,7 +261,7 @@ static void create_tag(const struct object_id *object, const char *tag, }if (opt->cleanup_mode !=CLEANUP_NONE ) -strbuf_stripspace (buf, opt->cleanup_mode ==CLEANUP_ALL ); +strbuf_stripspace (buf, opt->cleanup_mode ==CLEANUP_ALL ,0 );if (!opt->message_given && !buf->len)die (_ ("no tag message?" ));
rebase-interactive.c +1 -1
@@ -61,7 +61,7 @@ int edit_todo_list(struct repository *r, unsigned flags)if (strbuf_read_file (&buf, todo_file,0 ) <0 )return error_errno (_ ("could not read '%s'." ), todo_file); -strbuf_stripspace (&buf,1 ); +strbuf_stripspace (&buf,1 ,0 );if (write_message (buf.buf, buf.len, todo_file,0 )) {strbuf_release (&buf);return -1 ;
sequencer.c +3 -3
@@ -1041,7 +1041,7 @@ int template_untouched(const struct strbuf *sb, const char *template_file,if (!template_file ||strbuf_read_file (&tmpl, template_file,0 ) <=0 )return 0 ; -strbuf_stripspace (&tmpl, cleanup_mode ==COMMIT_MSG_CLEANUP_ALL ); +strbuf_stripspace (&tmpl, cleanup_mode ==COMMIT_MSG_CLEANUP_ALL ,0 );if (!skip_prefix (sb->buf, tmpl.buf, &start)) start = sb->buf;strbuf_release (&tmpl);
@@ -1386,7 +1386,7 @@ static int try_to_commit(struct repository *r, opts->default_msg_cleanup;if (cleanup !=COMMIT_MSG_CLEANUP_NONE ) -strbuf_stripspace (msg, cleanup ==COMMIT_MSG_CLEANUP_ALL ); +strbuf_stripspace (msg, cleanup ==COMMIT_MSG_CLEANUP_ALL ,0 );if ((flags &EDIT_MSG ) &&message_is_empty (msg, cleanup)) { res =1 ;/* run 'git commit' to display error message */ goto out;
@@ -4941,7 +4941,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned flareturn -1 ; } -strbuf_stripspace (buf,1 ); +strbuf_stripspace (buf,1 ,0 );if (buf->len ==0 ) {apply_autostash (opts);sequencer_remove_state (opts);
strbuf.c +63 -1
79 lines not on this page · raw message
strbuf.h +7 -1
@@ -499,8 +499,14 @@ int strbuf_normalize_path(struct strbuf *sb);/** * Strip whitespace from a buffer. The second parameter controls if * comments are considered contents to be removed or not. +* The third parameter controls if backslashes are escaped. */ -void strbuf_stripspace (struct strbuf *buf,int skip_comments); +void strbuf_stripspace (struct strbuf *buf,int skip_comments, +int escape_backslash); + +void strbuf_escape_backslash (struct strbuf *sb); + +void strbuf_addbackslash (struct strbuf *sb);static inline int strbuf_strip_suffix (struct strbuf *sb,const char *suffix) {
t/t7526-commit-message-comments.sh new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.21.0-rc0
Quoted 10 lines · Matthieu Moy
Quoted 2 lines
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.
How about --cleanup=scissors? The chance that you have the same cut line in your commit message is really low, compared to having comment characters.
Signature · 1 line
Duy
Quoted 11 lines · Duy Nguyen
Quoted 9 lines · Matthieu Moy
Quoted 2 lines
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(-)
Quoted 3 lines
Quoted 1 line
You really don't want that in day-to-day use.
How about --cleanup=scissors?
I can read this in two different ways:
1) Keeping git as-is and suggest users to use --cleanup=scissors
This has the same problem as --cleanup=verbatim: it doesn't work as-is since Git doesn't insert the scissors. You can hack around it by adding them by yourself when you need it, but it's really not convenient. You have to anticipate that you're going to require a # and call commit with --cleanup=scissors, add the scissors. And repeat it if you need to "commit --amend".
2) Modify Git to add scissors by default, and use --cleanup=scissors by default.
This is actually more or less what SVN does: it inserts a line "--This line, and those below, will be ignored--", and the equivalent of what Git adds as comments in the template is inserted below this line.
I don't think option 1) is good. The fact that we have the --cleanup= option shouldn't serve as an excuse to do nothing. I'd be fine with option 2), but I find it much more intrusive than to allow a simple backslash-escaping as I suggest.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 36 lines · Matthieu Moy
Quoted 11 lines · Duy Nguyen
Quoted 9 lines · Matthieu Moy
Quoted 2 lines
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(-)Quoted 3 lines
Quoted 1 line
You really don't want that in day-to-day use.
How about --cleanup=scissors?
I can read this in two different ways:
1) Keeping git as-is and suggest users to use --cleanup=scissors
This has the same problem as --cleanup=verbatim: it doesn't work as-is since Git doesn't insert the scissors. You can hack around it by adding them by yourself when you need it, but it's really not convenient. You have to anticipate that you're going to require a # and call commit with --cleanup=scissors, add the scissors. And repeat it if you need to "commit --amend".
2) Modify Git to add scissors by default, and use --cleanup=scissors by default.
This is actually more or less what SVN does: it inserts a line "--This line, and those below, will be ignored--", and the equivalent of what Git adds as comments in the template is inserted below this line.
Quoted 4 lines
I don't think option 1) is good. The fact that we have the --cleanup= option shouldn't serve as an excuse to do nothing. I'd be fine with option 2), but I find it much more intrusive than to allow a simple backslash-escaping as I suggest.
auto backslashing could cause some annoyance. Emacs supports rearranging a paragraph to fit in a fixed text column. This generated backslash may be moved around, no longer at the beginning of the line, and it will remain in the commit message. I don't know how popular this feature is outside emacs.
Having said that, even scissors has its own (and probably bigger)
problem: when you commit after conflict resolution, git inserts a "Conflicts:" paragraph, prepended by core.commentChar. With default settings, it serves as a reminder, but will be automatically stripped. With scissors, it stays by default because it's placed before the scissor line.
Signature · 1 line
Duy
Quoted 17 lines · Matthieu Moy
Quoted 15 lines · Duy Nguyen
Quoted 13 lines · Matthieu Moy
Quoted 2 lines
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(-)
Quoted 1 line
Quoted 1 line
Quoted 1 line
You really don't want that in day-to-day use.
I do not quite follow this example.
The user said "I'll be responsible for cleaning up" by giving the option. It is up to the user to use an editor that is something a bit more intelligent than "touch" to remove the instructional comments meant for humans after reading them.
Quoted 2 lines
2) Modify Git to add scissors by default, and use --cleanup=scissors by default.
I just did "$ git commit --amend --cleanup=scissors" (with and without --amend) and it seems to do exactly that ;-).
Quoted 19 lines · Junio C Hamano
Quoted 17 lines · Matthieu Moy
Quoted 15 lines · Duy Nguyen
Quoted 13 lines · Matthieu Moy
Quoted 2 lines
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(-)
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
You really don't want that in day-to-day use.
I do not quite follow this example.
The user said "I'll be responsible for cleaning up" by giving the option. It is up to the user to use an editor that is something a bit more intelligent than "touch" to remove the instructional comments meant for humans after reading them.
Yes, --cleanup=verbatim does what it says it does. Now, my claim is that it does not answer the use-case "I want an easy way to talk about # in a commit message". First, you have to specify --cleanup=verbatim _before_ typing the message, hence before knowing that you may need a #.
Then, as you say, it is up to the user to remove things that Git has added. Why would we ask the user to do this when we have a way to have the tool do it?
Quoted 5 lines
Quoted 2 lines
2) Modify Git to add scissors by default, and use --cleanup=scissors by default.
I just did "$ git commit --amend --cleanup=scissors" (with and without --amend) and it seems to do exactly that ;-).
Ah, I did my test in the same repo I messed-up with --cleanup=verbatim. It's better than I thought then. So a viable alternative to the backslas-escaping would be to change commit.cleanup to scissors by default.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 3 lines · Matthieu Moy
Then, as you say, it is up to the user to remove things that Git has added. Why would we ask the user to do this when we have a way to have the tool do it?
The timeline of development, perhaps? I thought cleanup=scissors was a fairly recent invention that hasn't been used widely yet.