Skip to content

Commit 1ae85ff

Browse files
ossilatorj6t
authored andcommitted
git-gui: strip comments and consecutive empty lines from commit messages
This is also known as "washing". This is consistent with the behavior of interactive git commit, which we should emulate as closely as possible to avoid usability problems. This way commit message templates and prepare hooks can be used properly, and comments from conflicted rebases and merges are cleaned up without having to introduce special handling for them. Signed-off-by: Oswald Buddenhagen <[email protected]> Signed-off-by: Johannes Sixt <[email protected]>
1 parent 2864e85 commit 1ae85ff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/commit.tcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ You must stage at least 1 file before you can commit.
209209
#
210210
set msg [string trim [$ui_comm get 1.0 end]]
211211
regsub -all -line {[ \t\r]+$} $msg {} msg
212+
# Strip comment lines
213+
regsub -all {(^|\n)#[^\n]*} $msg {\1} msg
214+
# Compress consecutive empty lines
215+
regsub -all {\n{3,}} $msg "\n\n" msg
212216
if {$msg eq {}} {
213217
error_popup [mc "Please supply a commit message.
214218

0 commit comments

Comments
 (0)