Skip to content

Commit 3fb6245

Browse files
kvaneeshJunio C Hamano
authored andcommitted
blameview: Support browsable functionality to blameview.
Double clicking on the row execs a new blameview with commit hash as argument. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 0417941 commit 3fb6245

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

contrib/blameview/blameview.perl

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
use Gtk2 -init;
44
use Gtk2::SimpleList;
55

6-
my $fn = shift or die "require filename to blame";
6+
my $hash;
7+
my $fn;
8+
if ( @ARGV == 1 ) {
9+
$hash = "HEAD";
10+
$fn = shift;
11+
} elsif ( @ARGV == 2 ) {
12+
$hash = shift;
13+
$fn = shift;
14+
} else {
15+
die "Usage blameview [<rev>] <filename>";
16+
}
717

818
Gtk2::Rc->parse_string(<<'EOS');
919
style "treeview_style"
@@ -27,17 +37,24 @@
2737
$fileview->get_column(0)->set_spacing(0);
2838
$fileview->set_size_request(1024, 768);
2939
$fileview->set_rules_hint(1);
40+
$fileview->signal_connect (row_activated => sub {
41+
my ($sl, $path, $column) = @_;
42+
my $row_ref = $sl->get_row_data_from_path ($path);
43+
system("blameview @$row_ref[0] $fn");
44+
# $row_ref is now an array ref to the double-clicked row's data.
45+
});
3046

3147
my $fh;
32-
open($fh, '-|', "git cat-file blob HEAD:$fn")
48+
open($fh, '-|', "git cat-file blob $hash:$fn")
3349
or die "unable to open $fn: $!";
50+
3451
while(<$fh>) {
3552
chomp;
3653
$fileview->{data}->[$.] = ['HEAD', '?', "$fn:$.", $_];
3754
}
3855

3956
my $blame;
40-
open($blame, '-|', qw(git blame --incremental --), $fn)
57+
open($blame, '-|', qw(git blame --incremental --), $fn, $hash)
4158
or die "cannot start git-blame $fn";
4259

4360
Glib::IO->add_watch(fileno($blame), 'in', \&read_blame_line);

0 commit comments

Comments
 (0)