Fix cat_file. (trivial)
[catagits/Gitalist.git] / lib / Gitalist / Model / Git.pm
index 1a27077..0a1f518 100644 (file)
@@ -41,6 +41,8 @@ sub build_per_context_instance {
   return $model;
 }
 
+__PACKAGE__->meta->make_immutable;
+
 package Git::Repos; # Better name? Split out into own file once we have a sane name.
 use Moose;
 use namespace::autoclean;
@@ -379,7 +381,7 @@ Return the contents of a given file.
 sub cat_file {
   my ($self, $object, $project) = @_;
 
-  my $type = $self->get_object_type($object, $project);
+  my $type = $self->get_object_type($object, $project || $self->project);
   die "object `$object' is not a file\n"
     if (!defined $type || $type ne 'blob');
 
@@ -480,10 +482,10 @@ sub diff {
   # So either a parent is specifed, or we use the commit's parent if there's
   # only one, otherwise it was a merge commit.
   my $parent = $args{parent}
-                        ? $args{parent}
-                        : @{$args{commit}->parents} <= 1
-                          ? $args{commit}->parent_sha1
-                          : '-c';
+             ? $args{parent}
+             : $args{commit}->parents <= 1
+               ? $args{commit}->parent_sha1
+               : '-c';
   my @etc = (
     ( $args{file}  ? ('--', $args{file}) : () ),
   );
@@ -610,7 +612,6 @@ sub list_revs {
     );
   }
 
-  $DB::single=1;
   my $output = $self->run_cmd_in($args{project} || $self->project, 'rev-list',
     '--header',
     (defined $args{ count  } ? "--max-count=$args{count}" : ()),