Skip to content

Commit

Permalink
git-gui: Display original filename and line number in blame.
Browse files Browse the repository at this point in the history
When we annotate a file and show its line data, we're already asking
for copy and movement detection (-M -C).  This costs extra time, but
gives extra data.  Since we are asking for the extra data we really
should show it to the user.

Now the blame UI has two additional columns, one for the original
filename (in the case of a move/copy between files) and one for the
original line number of the current line of code.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Shawn O. Pearce committed Jan 29, 2007
1 parent 8f6c07b commit 915616e
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3190,6 +3190,25 @@ proc show_blame {commit path} {
$w.out add $w.out.date
lappend texts $w.out.date

text $w.out.filename -background white -borderwidth 0 \
-state disabled \
-wrap none \
-height 40 \
-width 20 \
-font font_diff
$w.out add $w.out.filename
lappend texts $w.out.filename

text $w.out.origlinenumber -background white -borderwidth 0 \
-state disabled \
-wrap none \
-height 40 \
-width 5 \
-font font_diff
$w.out.origlinenumber tag conf linenumber -justify right
$w.out add $w.out.origlinenumber
lappend texts $w.out.origlinenumber

text $w.out.linenumber -background white -borderwidth 0 \
-state disabled \
-wrap none \
Expand Down Expand Up @@ -3286,7 +3305,9 @@ proc read_blame_catfile {fd w commit path texts w_lno w_file} {
}
}

proc read_blame_incremental {fd w w_commit w_author w_date w_lno w_file} {
proc read_blame_incremental {fd w
w_commit w_author w_date w_filename w_olno
w_lno w_file} {
global blame_status blame_data

if {![winfo exists $w_commit]} {
Expand All @@ -3297,6 +3318,8 @@ proc read_blame_incremental {fd w w_commit w_author w_date w_lno w_file} {
$w_commit conf -state normal
$w_author conf -state normal
$w_date conf -state normal
$w_filename conf -state normal
$w_olno conf -state normal

while {[gets $fd line] >= 0} {
if {[regexp {^([a-z0-9]{40}) (\d+) (\d+) (\d+)$} $line line \
Expand All @@ -3308,6 +3331,7 @@ proc read_blame_incremental {fd w w_commit w_author w_date w_lno w_file} {
} elseif {[string match {filename *} $line]} {
set n $blame_data($w,line_count)
set lno $blame_data($w,final_line)
set ol $blame_data($w,original_line)
set file [string range $line 9 end]
set commit $blame_data($w,commit)
set abbrev [string range $commit 0 8]
Expand All @@ -3327,14 +3351,20 @@ proc read_blame_incremental {fd w w_commit w_author w_date w_lno w_file} {
$w_commit delete $lno.0 "$lno.0 lineend"
$w_author delete $lno.0 "$lno.0 lineend"
$w_date delete $lno.0 "$lno.0 lineend"
$w_filename delete $lno.0 "$lno.0 lineend"
$w_olno delete $lno.0 "$lno.0 lineend"

$w_commit insert $lno.0 $abbrev
$w_author insert $lno.0 $author
$w_date insert $lno.0 $atime
$w_filename insert $lno.0 $file
$w_olno insert $lno.0 $ol linenumber

set blame_data($w,line$lno,commit) $commit

incr n -1
incr lno
incr ol
}
} elseif {[regexp {^([a-z-]+) (.*)$} $line line header data]} {
set blame_data($w,$blame_data($w,commit),$header) $data
Expand All @@ -3344,6 +3374,8 @@ proc read_blame_incremental {fd w w_commit w_author w_date w_lno w_file} {
$w_commit conf -state disabled
$w_author conf -state disabled
$w_date conf -state disabled
$w_filename conf -state disabled
$w_olno conf -state disabled

if {[eof $fd]} {
close $fd
Expand Down

0 comments on commit 915616e

Please sign in to comment.