mirror of
https://github.com/git/git.git
synced 2024-11-18 05:53:54 +01:00
git-gui: Show author initials in blame groups
Frequently when I'm looking at blocks of code in the blame viewer I want to know who is the culprit, or who I should be praising for a job well done. The tooltips nicely show this if I mouse over a block, but it doesn't work to get this detail at a glance. Since we don't use the leftmost commit column for anything after the first line within a commit group I'm now tossing the author's initials into that field, right justified. It is quite clearly not a SHA-1 number as we always show the SHA-1 in lowercase, while we explicitly select only the uppercase characters from an author's name field, and only those that are following whitespace. I'm using initials here over anything else as they are quite commonly unique within small development teams. The leading part of the email address field was out for some of the teams I work with, as there the email addresses are all of the form "Givenname.Surname@initech.com". That will never fit into the 4 characters available. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
ddc1fa8f88
commit
223475a77c
@ -294,15 +294,38 @@ method _read_blame {fd} {
|
||||
set cmit $r_commit
|
||||
|
||||
if {[regexp {^0{40}$} $cmit]} {
|
||||
set abbr work
|
||||
set commit_abbr work
|
||||
} else {
|
||||
set abbr [string range $cmit 0 4]
|
||||
set commit_abbr [string range $cmit 0 4]
|
||||
}
|
||||
|
||||
if {![catch {set ncmit $line_commit([expr {$lno - 1}])}]} {
|
||||
if {$ncmit eq $cmit} {
|
||||
set abbr { |}
|
||||
set author_abbr {}
|
||||
set a_name {}
|
||||
catch {set a_name $header($cmit,author)}
|
||||
while {$a_name ne {}} {
|
||||
if {![regexp {^([[:upper:]])} $a_name _a]} break
|
||||
append author_abbr $_a
|
||||
unset _a
|
||||
if {![regsub \
|
||||
{^[[:upper:]][^\s]*\s+} \
|
||||
$a_name {} a_name ]} break
|
||||
}
|
||||
if {$author_abbr eq {}} {
|
||||
set author_abbr { |}
|
||||
} else {
|
||||
set author_abbr [string range $author_abbr 0 3]
|
||||
while {[string length $author_abbr] < 4} {
|
||||
set author_abbr " $author_abbr"
|
||||
}
|
||||
}
|
||||
unset a_name
|
||||
|
||||
set first_lno $lno
|
||||
while {
|
||||
![catch {set ncmit $line_commit([expr {$first_lno - 1}])}]
|
||||
&& $ncmit eq $cmit
|
||||
} {
|
||||
incr first_lno -1
|
||||
}
|
||||
|
||||
while {$n > 0} {
|
||||
@ -323,8 +346,13 @@ method _read_blame {fd} {
|
||||
set line_file($lno) $file
|
||||
|
||||
$w_cgrp delete $lno.0 "$lno.0 lineend"
|
||||
$w_cgrp insert $lno.0 $abbr
|
||||
set abbr { |}
|
||||
if {$lno == $first_lno} {
|
||||
$w_cgrp insert $lno.0 $commit_abbr
|
||||
} elseif {$lno == [expr {$first_lno + 1}]} {
|
||||
$w_cgrp insert $lno.0 $author_abbr
|
||||
} else {
|
||||
$w_cgrp insert $lno.0 { |}
|
||||
}
|
||||
|
||||
$w_cgrp tag add g$cmit $lno.0 $lno_e
|
||||
$w_line tag add g$cmit $lno.0 $lno_e
|
||||
@ -348,12 +376,20 @@ method _read_blame {fd} {
|
||||
incr blame_lines
|
||||
}
|
||||
|
||||
if {![catch {set ncmit $line_commit($lno)}]} {
|
||||
if {$ncmit eq $cmit} {
|
||||
$w_cgrp delete $lno.0 "$lno.0 lineend + 1c"
|
||||
$w_cgrp insert $lno.0 " |\n"
|
||||
while {![catch {set ncmit $line_commit($lno)}]
|
||||
&& $ncmit eq $cmit} {
|
||||
$w_cgrp delete $lno.0 "$lno.0 lineend"
|
||||
|
||||
if {$lno == $first_lno} {
|
||||
$w_cgrp insert $lno.0 $commit_abbr
|
||||
} elseif {$lno == [expr {$first_lno + 1}]} {
|
||||
$w_cgrp insert $lno.0 $author_abbr
|
||||
} else {
|
||||
$w_cgrp insert $lno.0 { |}
|
||||
}
|
||||
incr lno
|
||||
}
|
||||
|
||||
} elseif {[regexp {^([a-z-]+) (.*)$} $line line key data]} {
|
||||
set header($r_commit,$key) $data
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user