summaryrefslogtreecommitdiff
path: root/gitk
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-09-27 00:56:02 (GMT)
committerPaul Mackerras <paulus@samba.org>2007-06-23 10:55:43 (GMT)
commit43c25074381dea404518318dacd360ed4f2abf3d (patch)
treeb50a392dfc55ee9468fca78ec7510e3ef2b620d1 /gitk
parent7eb3cb9c683624681541972910328054e9431b43 (diff)
downloadgit-43c25074381dea404518318dacd360ed4f2abf3d.zip
git-43c25074381dea404518318dacd360ed4f2abf3d.tar.gz
git-43c25074381dea404518318dacd360ed4f2abf3d.tar.bz2
gitk: Cope with commit messages with carriage-returns and initial blank lines
In some repositories imported from other systems we can get carriage return characters in the commit message, which leads to a multi-line headline being displayed in the summary window, which looks bad. Also some commit messages start with one or more blank lines, which leads to an empty headline. This fixes these problems. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'gitk')
-rwxr-xr-xgitk20
1 files changed, 14 insertions, 6 deletions
diff --git a/gitk b/gitk
index 1b573e0..0c2767d 100755
--- a/gitk
+++ b/gitk
@@ -341,12 +341,16 @@ proc parsecommit {id contents listed} {
}
}
set headline {}
- # take the first line of the comment as the headline
- set i [string first "\n" $comment]
+ # take the first non-blank line of the comment as the headline
+ set headline [string trimleft $comment]
+ set i [string first "\n" $headline]
if {$i >= 0} {
- set headline [string trim [string range $comment 0 $i]]
- } else {
- set headline $comment
+ set headline [string range $headline 0 $i]
+ }
+ set headline [string trimright $headline]
+ set i [string first "\r" $headline]
+ if {$i >= 0} {
+ set headline [string trimright [string range $headline 0 $i]]
}
if {!$listed} {
# git rev-list indents the comment by 4 spaces;
@@ -4157,7 +4161,11 @@ proc selectline {l isnew} {
dispneartags 1
}
$ctext insert end "\n"
- appendwithlinks [lindex $info 5] {comment}
+ set comment [lindex $info 5]
+ if {[string first "\r" $comment] >= 0} {
+ set comment [string map {"\r" "\n "} $comment]
+ }
+ appendwithlinks $comment {comment}
$ctext tag delete Comments
$ctext tag remove found 1.0 end