git-diff-blame icon indicating copy to clipboard operation
git-diff-blame copied to clipboard

Errors when running

Open ericfreese opened this issue 8 years ago • 2 comments

Hi, I'm getting some errors trying to run git diff-blame

Use of uninitialized value $prefilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 54, <$diff> line 1.
Use of uninitialized value $postfilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 57, <$diff> line 1.
Use of uninitialized value $prefilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 54, <$diff> line 2.
Use of uninitialized value $postfilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 57, <$diff> line 2.
Use of uninitialized value $prefilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 54, <$diff> line 3.
Use of uninitialized value $postfilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 57, <$diff> line 3.
Use of uninitialized value $prefilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 54, <$diff> line 4.
Use of uninitialized value $postfilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 57, <$diff> line 4.
Use of uninitialized value $prefilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 54, <$diff> line 5.
Use of uninitialized value $postfilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 57, <$diff> line 5.
Use of uninitialized value $prefilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 54, <$diff> line 6.
Use of uninitialized value $postfilename in regexp compilation at /Users/ericfreese/bin/git-diff-blame line 57, <$diff> line 6.
Use of uninitialized value $pre in <HANDLE> at /Users/ericfreese/bin/git-diff-blame line 79.
readline() on unopened filehandle at /Users/ericfreese/bin/git-diff-blame line 79.
Use of uninitialized value $line in pattern match (m//) at /Users/ericfreese/bin/git-diff-blame line 21.
Use of uninitialized value $line in concatenation (.) or string at /Users/ericfreese/bin/git-diff-blame line 21.
bad blame output:  at /Users/ericfreese/bin/git-diff-blame line 21.

I'm on OSX with perl v5.18.2.

Any thoughts on what could be causing this? I haven't looked too deeply myself, but I haven't worked with perl in years...

ericfreese avatar Jan 26 '17 15:01 ericfreese

I ran into some variation of this, some of which seem related to how git is configured to format diffs. The 'diff.noprefix' and 'diff.mnemonicPrefix' iirc. Settings those back to the default seemed to make progress.

I managed to munge it to work for the case I needed with this patch (warning: I don't know perl...):

diff --git a/git-diff-blame b/git-diff-blame
index faf7075..5fc9006 100755
--- a/git-diff-blame
+++ b/git-diff-blame
@@ -18,8 +18,12 @@ sub parse_hunk_header {
 
 sub get_blame_prefix {
        my ($line) = @_;
-       $line =~ /^(\^?[0-9a-f]+\s+(\S+\s+)?\([^\)]+\))/ or die "bad blame output: $line";
-       return $1;
+    if ($line) {
+           $line =~ /^(\^?[0-9a-f]+\s+(\S+\s+)?\([^\)]+\))/ or die "bad blame output: $line";
+        return $1;
+    } else {
+        return ;
+    }
 }
 
 $git_root = `git rev-parse --show-toplevel`;
@@ -27,10 +31,10 @@ $git_root =~ s/^\s+//;
 $git_root =~ s/\s+$//;
 chdir($git_root) or die "$!";
 
-my ($oldrev, $newrev) = @ARGV;
+my ($oldrev, $newrev, @REST) = @ARGV;
 $oldrev ||= 'HEAD';
 if ($newrev) {
-       open($diff, '-|', 'git', '--no-pager', 'diff', $oldrev, $newrev) or die;
+       open($diff, '-|', 'git', '--no-pager', 'diff', $oldrev, $newrev, @REST) or die;
 } else {
        open($diff, '-|', 'git', '--no-pager', 'diff', $oldrev) or die;
 }

alikins avatar Jun 30 '17 15:06 alikins