summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-01-25 12:54:59 -0500
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-01-25 12:54:59 -0500
commit4e55d19a1377de55c950a90c10b31ae37b79363d (patch)
tree1544b9466957b391e27096ac0d8ee3f0b1b10dd0 /git-gui.sh
parentgit-gui: Elide CRs appearing in diff output from display. (diff)
downloadtgif-4e55d19a1377de55c950a90c10b31ae37b79363d.tar.xz
git-gui: Cleanup end-of-line whitespace in commit messages.
When committing changes its useless to have trailing whitespace on the end of a line within the commit message itself; this serves no purpose beyond wasting space in the repository. But it happens a lot on my Mac OS X system if I copy text out of a Terminal.app window and paste it into git-gui. We now clip any trailing whitespace from the commit buffer when loading it from a file, when saving it out to our backup file, or when making the actual commit object. I also fixed a bug where we lost the commit message buffer if you quit without editing the text region. This can happen if you quit and restart git-gui frequently in the middle of an editing session. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh9
1 files changed, 6 insertions, 3 deletions
diff --git a/git-gui.sh b/git-gui.sh
index ee7fdaabfd..5d418b99c8 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -428,6 +428,7 @@ proc load_message {file} {
}
set content [string trim [read $fd]]
close $fd
+ regsub -all -line {[ \r\t]+$} $content {} content
$ui_comm delete 0.0 end
$ui_comm insert end $content
return 1
@@ -1046,6 +1047,7 @@ You must add at least 1 file before you can commit.
# -- A message is required.
#
set msg [string trim [$ui_comm get 1.0 end]]
+ regsub -all -line {[ \t\r]+$} $msg {} msg
if {$msg eq {}} {
error_popup {Please supply a commit message.
@@ -2984,12 +2986,13 @@ proc do_quit {} {
#
set save [gitdir GITGUI_MSG]
set msg [string trim [$ui_comm get 0.0 end]]
- if {![string match amend* $commit_type]
- && [$ui_comm edit modified]
+ regsub -all -line {[ \r\t]+$} $msg {} msg
+ if {(![string match amend* $commit_type]
+ || [$ui_comm edit modified])
&& $msg ne {}} {
catch {
set fd [open $save w]
- puts $fd [string trim [$ui_comm get 0.0 end]]
+ puts -nonewline $fd $msg
close $fd
}
} else {