Skip to content

Commit 0511798

Browse files
committed
git-gui: Cleanup minor nits in blame code
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 <[email protected]>
1 parent a0db0d6 commit 0511798

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

lib/blame.tcl

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ constructor new {i_commit i_path} {
166166
bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
167167
}
168168

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

173173
if {$commit eq {}} {
@@ -237,17 +237,18 @@ method _read_blame {fd} {
237237
set cmit $r_commit
238238

239239
while {$n > 0} {
240+
set lno_e "$lno.0 lineend + 1c"
240241
if {[catch {set g g$line_commit($lno)}]} {
241-
$w_load tag add annotated $lno.0 "$lno.0 lineend + 1c"
242+
$w_load tag add annotated $lno.0 $lno_e
242243
} else {
243-
$w_line tag remove g$g $lno.0 "$lno.0 lineend + 1c"
244-
$w_file tag remove g$g $lno.0 "$lno.0 lineend + 1c"
244+
$w_line tag remove g$g $lno.0 $lno_e
245+
$w_file tag remove g$g $lno.0 $lno_e
245246
}
246247

247248
set line_commit($lno) $cmit
248249
set line_file($lno) $file
249-
$w_line tag add g$cmit $lno.0 "$lno.0 lineend + 1c"
250-
$w_file tag add g$cmit $lno.0 "$lno.0 lineend + 1c"
250+
$w_line tag add g$cmit $lno.0 $lno_e
251+
$w_file tag add g$cmit $lno.0 $lno_e
251252

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

300+
set lno_e "$lno.0 + 1 line"
299301
$w_line tag remove in_sel 0.0 end
300302
$w_file tag remove in_sel 0.0 end
301-
$w_line tag add in_sel $lno.0 "$lno.0 + 1 line"
302-
$w_file tag add in_sel $lno.0 "$lno.0 + 1 line"
303+
$w_line tag add in_sel $lno.0 $lno_e
304+
$w_file tag add in_sel $lno.0 $lno_e
303305

304306
_showcommit $this $lno
305307
}
@@ -327,8 +329,7 @@ method _showcommit {lno} {
327329

328330
$w_cmit conf -state normal
329331
$w_cmit delete 0.0 end
330-
if {[catch {set cmit $line_commit($lno)} myerr]} {
331-
puts "myerr = $myerr"
332+
if {[catch {set cmit $line_commit($lno)}]} {
332333
set cmit {}
333334
$w_cmit insert end "Loading annotation..."
334335
} else {
@@ -381,12 +382,12 @@ method _showcommit {lno} {
381382
set header($cmit,message) $msg
382383
}
383384

384-
$w_cmit insert end "commit $cmit\n"
385-
$w_cmit insert end "Author: $author_name $author_email $author_time\n"
386-
$w_cmit insert end "Committer: $committer_name $committer_email $committer_time\n"
387-
$w_cmit insert end "Original File: [escape_path $line_file($lno)]\n"
388-
$w_cmit insert end "\n"
389-
$w_cmit insert end $msg
385+
$w_cmit insert end "commit $cmit
386+
Author: $author_name $author_email $author_time
387+
Committer: $committer_name $committer_email $committer_time
388+
Original File: [escape_path $line_file($lno)]
389+
390+
$msg"
390391
}
391392
$w_cmit conf -state disabled
392393

0 commit comments

Comments
 (0)