summaryrefslogtreecommitdiffstats
path: root/gitBlameFromLineNo
blob: 432e3fad79cc0374d08595e625eddb4ef8d0e85b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl

use strict;
use warnings;

use v5.10;

my $debug = 0;

my $line_no = $ARGV[0];
my $file_name = $ARGV[1];
say "Line: $line_no | File: $file_name" if $debug;

# Get the git blame for the line & file
my $line = `git blame -L $line_no,$line_no $file_name`;
say "Line: $line" if $debug;

# Reduce this just to the SHA
chomp $line;
(my $sha = $line) =~ s/^(\S+).*/$1/;
say "SHA: $sha" if $debug;

# Show the commit for that SHA
system("git show $sha");