Skip to content

Commit 80983c4

Browse files
committed
git-gui: do not end the commit message with an empty line
The commit message is processed to remove unnecessary empty lines. In particular, it is ensured that the text ends with at most one LF character. This one is always present, because the Tk text widget ensures that is present. However, did not consider that the processed text is written to the commit message file using `puts`, which also appends a LF character, so that the final commit message ends with two LF. Trim all trailing LF characters, and while we are here, use `string trim`, which lets us remove the leading LF in the same command. Reported-by: Gareth Fenn <[email protected]> Reviewed-by: Oswald Buddenhagen <[email protected]> Signed-off-by: Johannes Sixt <[email protected]>
1 parent 6b43a57 commit 80983c4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/commit.tcl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,10 @@ You must stage at least 1 file before you can commit.
214214
global comment_string
215215
set cmt_rx [strcat {(^|\n)} [regsub -all {\W} $comment_string {\\&}] {[^\n]*}]
216216
regsub -all $cmt_rx $msg {\1} msg
217-
# Strip leading empty lines
218-
regsub {^\n*} $msg {} msg
217+
# Strip leading and trailing empty lines (puts adds one \n)
218+
set msg [string trim $msg \n]
219219
# Compress consecutive empty lines
220220
regsub -all {\n{3,}} $msg "\n\n" msg
221-
# Strip trailing empty line
222-
regsub {\n\n$} $msg "\n" msg
223221
if {$msg eq {}} {
224222
error_popup [mc "Please supply a commit message.
225223

0 commit comments

Comments
 (0)