@matheusbsbs / matheus-bagliano / commits / 3fb624521e
Fork 0

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>

Aneesh Kumar K.V committed Jan 30, 2007 at 13:26 UTC 3fb624521e059c6c3caef470a9ff03f72b86036c
1 file changed +20 -3
contrib/blameview/blameview.perl
+20 -3
@@ -3,7 +3,17 @@
3 use Gtk2 -init;
4 use Gtk2::SimpleList;
5
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 +}
17
18 Gtk2::Rc->parse_string(<<'EOS');
19 style "treeview_style"
@@ -27,17 +37,24 @@ $scrolled_window->add($fileview);
37 $fileview->get_column(0)->set_spacing(0);
38 $fileview->set_size_request(1024, 768);
39 $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 + });
46
47 my $fh;
32 -open($fh, '-|', "git cat-file blob HEAD:$fn")
48 +open($fh, '-|', "git cat-file blob $hash:$fn")
49 or die "unable to open $fn: $!";
50 +
51 while(<$fh>) {
52 chomp;
53 $fileview->{data}->[$.] = ['HEAD', '?', "$fn:$.", $_];
54 }
55
56 my $blame;
40 -open($blame, '-|', qw(git blame --incremental --), $fn)
57 +open($blame, '-|', qw(git blame --incremental --), $fn, $hash)
58 or die "cannot start git-blame $fn";
59
60 Glib::IO->add_watch(fileno($blame), 'in', \&read_blame_line);