Fix variable and blame bugs.
[catagits/Gitalist.git] / lib / Gitalist / Controller / Fragment / Ref.pm
index a2e02e3..718d195 100644 (file)
@@ -15,20 +15,21 @@ sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
 
 sub _diff {
     my ($self, $c) = @_;
-    my $commit = $c->stash->{Commit};
-    my %filename = $c->stash->{filename} ? (filename => $c->stash->{filename}) : ();
-    my($tree, $patch) = $c->stash->{Repository}->diff(
-        commit => $commit,
-        parent => $c->stash->{parent},
-        patch  => 1,
-        %filename,
+    my %diff_args = ( patch => 1 );
+    foreach my $arg qw/filename parent/ {
+        if (defined $c->stash->{$arg}) {
+            $diff_args{$arg} = $c->stash->{$arg};
+        };
+    };
+    my ($tree, $patch) = $c->stash->{Commit}->diff(
+        %diff_args,
     );
     $c->stash(
       diff_tree => $tree,
       diff      => $patch,
       # XXX Hack hack hack, see View::SyntaxHighlight
       blobs     => [map $_->{diff}, @$patch],
-      %filename,
+      %diff_args,
     );
 }
 
@@ -130,10 +131,10 @@ after file_commit_info => sub {
     my $json_obj = !$commit
                  ? { }
                  : {
-                    sha1    => $commit->sha1,
-                    comment => $c->stash->{short_cmt}->($commit->comment),
-                    age     => $c->stash->{time_since}->($commit->authored_time),
-                };
+                     sha1    => $commit->sha1,
+                     comment => $c->stash->{short_cmt}->($commit->comment),
+                     age     => $c->stash->{time_since}->($commit->authored_time),
+                 };
 
     $c->response->content_type('application/json');
     # XXX Make use of the json branch