@matheusbsbs / matheus-bagliano / commits / 0511798f06
Fork 0

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 <spearce@spearce.org>

Shawn O. Pearce committed May 9, 2007 at 00:36 UTC 0511798f06d3456885682605b54bd3bc378e8fda
1 file changed +18 -17
lib/blame.tcl
+18 -17
@@ -166,8 +166,8 @@ constructor new {i_commit i_path} {
166 bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
167 }
168
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]
171 bind $top <Destroy> [list delete_this $this]
172
173 if {$commit eq {}} {
@@ -237,17 +237,18 @@ method _read_blame {fd} {
237 set cmit $r_commit
238
239 while {$n > 0} {
240 + set lno_e "$lno.0 lineend + 1c"
241 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
243 } 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
246 }
247
248 set line_commit($lno) $cmit
249 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
252
253 if {$highlight_line == -1} {
254 if {[lindex [$w_file yview] 0] == 0} {
@@ -296,10 +297,11 @@ method _click {cur_w pos} {
297 set lno [lindex [split [$cur_w index $pos] .] 0]
298 if {$lno eq {}} return
299
300 + set lno_e "$lno.0 + 1 line"
301 $w_line tag remove in_sel 0.0 end
302 $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
305
306 _showcommit $this $lno
307 }
@@ -327,8 +329,7 @@ method _showcommit {lno} {
329
330 $w_cmit conf -state normal
331 $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)}]} {
333 set cmit {}
334 $w_cmit insert end "Loading annotation..."
335 } else {
@@ -381,12 +382,12 @@ method _showcommit {lno} {
382 set header($cmit,message) $msg
383 }
384
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"
391 }
392 $w_cmit conf -state disabled
393