Skip to content

Commit e503389

Browse files
committed
Merge branch 'ob/strip-comments-on-commit'
* ob/strip-comments-on-commit: git-gui: strip commit messages less aggressively git-gui: strip comments and consecutive empty lines from commit messages
2 parents 4925501 + 9093496 commit e503389

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/commit.tcl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,17 @@ You must stage at least 1 file before you can commit.
207207

208208
# -- A message is required.
209209
#
210-
set msg [string trim [$ui_comm get 1.0 end]]
210+
set msg [$ui_comm get 1.0 end]
211+
# Strip trailing whitespace
211212
regsub -all -line {[ \t\r]+$} $msg {} msg
213+
# Strip comment lines
214+
regsub -all {(^|\n)#[^\n]*} $msg {\1} msg
215+
# Strip leading empty lines
216+
regsub {^\n*} $msg {} msg
217+
# Compress consecutive empty lines
218+
regsub -all {\n{3,}} $msg "\n\n" msg
219+
# Strip trailing empty line
220+
regsub {\n\n$} $msg "\n" msg
212221
if {$msg eq {}} {
213222
error_popup [mc "Please supply a commit message.
214223

0 commit comments

Comments
 (0)