[PATCH 1/2] git-gui: strip comments and consecutive empty lines from commit messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <oswald.buddenhagen@xxxxxx>

---

Cc: Johannes Sixt <j6t@xxxxxxxx>
Cc: Brian Lyles <brianmlyles@xxxxxxxxx>
Cc: Junio C Hamano <gitster@xxxxxxxxx>
Cc: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
Cc: Sean Allred <allred.sean@xxxxxxxxx>
---
 git-gui/lib/commit.tcl | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
index 11379f8ad3..f00a634624 100644
--- a/git-gui/lib/commit.tcl
+++ b/git-gui/lib/commit.tcl
@@ -209,6 +209,10 @@ You must stage at least 1 file before you can commit.
 	#
 	set msg [string trim [$ui_comm get 1.0 end]]
 	regsub -all -line {[ \t\r]+$} $msg {} msg
+	# Strip comment lines
+	regsub -all {(^|\n)#[^\n]*} $msg {\1} msg
+	# Compress consecutive empty lines
+	regsub -all {\n{3,}} $msg "\n\n" msg
 	if {$msg eq {}} {
 		error_popup [mc "Please supply a commit message.
 
-- 
2.46.0.180.gb23db42a00





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux