Skip to content

Commit

Permalink
git-gui: Cleanup minor nits in blame code
Browse files Browse the repository at this point in the history
We can use [list ...] rather than "", especially when we are talking
about values as then they are properly escaped if necessary.  Small
nit, but probably not a huge deal as the only data being inlined here
is Tk paths.

Some of the lines in the parser code were longer than 80 characters
wide, and they actually were all the same value on the end part of
the line.  Rather than keeping the mess copied-and-pasted around we
can set the last argument into a local variable and reuse it many
times.

The commit display code was also rather difficult to read on an 80
character wide terminal, so I'm moving it all into a double quoted
string that is easier to read.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Shawn O. Pearce committed May 9, 2007
1 parent a0db0d6 commit 0511798
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions lib/blame.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ constructor new {i_commit i_path} {
bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
}

bind $w.cm.t <Button-1> "focus $w.cm.t"
bind $top <Visibility> "focus $top"
bind $w.cm.t <Button-1> [list focus $w.cm.t]
bind $top <Visibility> [list focus $top]
bind $top <Destroy> [list delete_this $this]

if {$commit eq {}} {
Expand Down Expand Up @@ -237,17 +237,18 @@ method _read_blame {fd} {
set cmit $r_commit

while {$n > 0} {
set lno_e "$lno.0 lineend + 1c"
if {[catch {set g g$line_commit($lno)}]} {
$w_load tag add annotated $lno.0 "$lno.0 lineend + 1c"
$w_load tag add annotated $lno.0 $lno_e
} else {
$w_line tag remove g$g $lno.0 "$lno.0 lineend + 1c"
$w_file tag remove g$g $lno.0 "$lno.0 lineend + 1c"
$w_line tag remove g$g $lno.0 $lno_e
$w_file tag remove g$g $lno.0 $lno_e
}

set line_commit($lno) $cmit
set line_file($lno) $file
$w_line tag add g$cmit $lno.0 "$lno.0 lineend + 1c"
$w_file tag add g$cmit $lno.0 "$lno.0 lineend + 1c"
$w_line tag add g$cmit $lno.0 $lno_e
$w_file tag add g$cmit $lno.0 $lno_e

if {$highlight_line == -1} {
if {[lindex [$w_file yview] 0] == 0} {
Expand Down Expand Up @@ -296,10 +297,11 @@ method _click {cur_w pos} {
set lno [lindex [split [$cur_w index $pos] .] 0]
if {$lno eq {}} return

set lno_e "$lno.0 + 1 line"
$w_line tag remove in_sel 0.0 end
$w_file tag remove in_sel 0.0 end
$w_line tag add in_sel $lno.0 "$lno.0 + 1 line"
$w_file tag add in_sel $lno.0 "$lno.0 + 1 line"
$w_line tag add in_sel $lno.0 $lno_e
$w_file tag add in_sel $lno.0 $lno_e

_showcommit $this $lno
}
Expand Down Expand Up @@ -327,8 +329,7 @@ method _showcommit {lno} {

$w_cmit conf -state normal
$w_cmit delete 0.0 end
if {[catch {set cmit $line_commit($lno)} myerr]} {
puts "myerr = $myerr"
if {[catch {set cmit $line_commit($lno)}]} {
set cmit {}
$w_cmit insert end "Loading annotation..."
} else {
Expand Down Expand Up @@ -381,12 +382,12 @@ method _showcommit {lno} {
set header($cmit,message) $msg
}

$w_cmit insert end "commit $cmit\n"
$w_cmit insert end "Author: $author_name $author_email $author_time\n"
$w_cmit insert end "Committer: $committer_name $committer_email $committer_time\n"
$w_cmit insert end "Original File: [escape_path $line_file($lno)]\n"
$w_cmit insert end "\n"
$w_cmit insert end $msg
$w_cmit insert end "commit $cmit
Author: $author_name $author_email $author_time
Committer: $committer_name $committer_email $committer_time
Original File: [escape_path $line_file($lno)]
$msg"
}
$w_cmit conf -state disabled

Expand Down

0 comments on commit 0511798

Please sign in to comment.