Skip to content

Commit 244a70e

Browse files
ltuikovJunio C Hamano
authored andcommitted
Blame "linenr" link jumps to previous state at "orig_lineno"
Blame currently displays the commit id which introduced a block of one or more lines, the line numbers wrt the current listing of the file and the file's line contents. The commit id displayed is hyperlinked to the commit. Currently the linenr links are hyperlinked to the same commit id displayed to the left, which is _no_ different than the block of lines displayed, since it is the _same commit_ that is hyperlinked. And thus clicking on it leads to the same state of the file for that chunk of lines. I.e. data mining is not currently possible with gitweb given a chunk of lines introduced by a commit. This patch makes such data mining possible. The line numbers are now hyperlinked to the parent of the commit id of the block of lines. Furthermore they are linked to the line where that block was introduced. Thus clicking on a linenr link will show you the file's line(s) state prior to the commit id you were viewing. So clicking continually on a linenr link shows you how this line and its line number changed over time, leading to the initial commit where it was first introduced. Signed-off-by: Luben Tuikov <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 27dd1a8 commit 244a70e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gitweb/gitweb.perl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3212,9 +3212,14 @@ sub git_blame2 {
32123212
esc_html($rev));
32133213
print "</td>\n";
32143214
}
3215+
open (my $dd, "-|", git_cmd(), "rev-parse", "$full_rev^")
3216+
or die_error("could not open git-rev-parse");
3217+
my $parent_commit = <$dd>;
3218+
close $dd;
3219+
chomp($parent_commit);
32153220
my $blamed = href(action => 'blame',
32163221
file_name => $meta->{'filename'},
3217-
hash_base => $full_rev);
3222+
hash_base => $parent_commit);
32183223
print "<td class=\"linenr\">";
32193224
print $cgi->a({ -href => "$blamed#l$orig_lineno",
32203225
-id => "l$lineno",

0 commit comments

Comments
 (0)