summaryrefslogtreecommitdiffstats
path: root/gitBlameFromLineNo
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-06-14 15:20:25 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-06-14 15:20:25 +0200
commit5afaf12a999b1c0c153c8e3620321a23b5506674 (patch)
tree8fdff20ebc0da6aba1e1124464908962c7624d6d /gitBlameFromLineNo
parent8d4c36cccdedc9889b071bf5ec46980afb4a6dfd (diff)
downloadbin-5afaf12a999b1c0c153c8e3620321a23b5506674.tar.gz
bin-5afaf12a999b1c0c153c8e3620321a23b5506674.tar.xz
add some new files; misc changes
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'gitBlameFromLineNo')
-rwxr-xr-xgitBlameFromLineNo24
1 files changed, 24 insertions, 0 deletions
diff --git a/gitBlameFromLineNo b/gitBlameFromLineNo
new file mode 100755
index 0000000..432e3fa
--- /dev/null
+++ b/gitBlameFromLineNo
@@ -0,0 +1,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"); \ No newline at end of file