Bug 580214 - The commit message input textbox does not seem to evaluate the commentChar=auto setting
Summary: The commit message input textbox does not seem to evaluate the commentChar=au...
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 6.2   Edit
Hardware: PC Windows 10
: P3 trivial (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-20 05:14 EDT by Simon Sohrt CLA
Modified: 2022-06-29 05:58 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Sohrt CLA 2022-06-20 05:14:35 EDT
When commentChar=auto is enabled, lines starting with '#' in the commit message input textbox are colored green, even though they are not comments. This behavior might confuse users. 

I see two solutions: 
1. Don't color in the input textbox at all. This is also the behavior of c-git and git gui. 
2. Evaluate the setting for commentChar and color the lines accordingly.
Comment 1 Thomas Wolf CLA 2022-06-20 11:42:19 EDT
Indeed, if there is a non-empty commit message and the setting is "auto", it should be evaluated.
Comment 2 Eclipse Genie CLA 2022-06-20 16:47:05 EDT
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/194318
Comment 3 Thomas Wolf CLA 2022-06-20 16:54:13 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/194318

The re-evaluates the comment character when "amend" is toggled in the Git Staging view. Otherwise I see no problem with the "auto" setting.

If the problem you reported was not related to amending a commit: please give concrete steps to reproduce. Are you using a commit message template?

Not syntax-coloring is a very bad idea; if it's colored as comment, EGit will treat it as a comment and remove it. If we don't syntax-color comments, users will be left wondering why some lines were removed.
Comment 5 Simon Sohrt CLA 2022-06-28 10:19:41 EDT
This bug is related to bug 580213. I would both turn on filtering of comment lines in commit message and syntax highlighting for comment lines only if git has inserted comments into the commit message itself. 

I believe that this makes sense conceptually: 
Commit comments are a way for git to talk to the user. So if git does not need to talk to the user all logic concerning comments should be deactivated. Based on my tests, this is also how c-git handles comments. 

It never makes sense for users to write commit messages because no one can read them. This is in contrast to how comments are usually used: As a way of talking to a future developer (or your future self).
Comment 6 Simon Sohrt CLA 2022-06-28 10:21:05 EDT
(In reply to Simon Sohrt from comment #5)
> It never makes sense for users to write commit messages because no one can
*comment messages
Comment 7 Thomas Wolf CLA 2022-06-28 15:54:14 EDT
Well: see bug 580213. EGit behaves like C git when the commit message is entered in an editor.

I can see the argument for EGit having different behavior if the commit message is initially empty and applying only commit.cleanup=whitespace in that case if the git config setting is strip or scissors. Might make sense since Egit does not, contrary to C git, pre-fill the editor with explanatory text. However, while this would allow committing with a message like "#123 foo", users then
might run into surprises when they rebase or merge and get conflicts, or similar things. Also squashing might then treat such lines as comments. Unless you set core.commentChar to some other character (or to auto). Or you change commit.cleanup=whitespace and remove comment lines manually.

So not much is gained; the problem is just postponed.

My recommendation if you want/need such commit messages: set core.commentChar=; . (Don't use auto, it'd still choose # for initially empty messages.)
Comment 8 Simon Sohrt CLA 2022-06-29 05:58:44 EDT
Thank you for your explanation and patience. After your changes I consider this bug resolved.