Introduce a run_cmd_fh method, to avoid slurping command output.
Zachary Stevens [Thu, 19 Nov 2009 21:32:00 +0000 (21:32 +0000)]
lib/Gitalist/Git/HasUtils.pm
lib/Gitalist/Git/Object.pm
lib/Gitalist/Git/Object/Commit.pm
lib/Gitalist/Git/Util.pm

index 2274304..8815b6a 100644 (file)
@@ -14,6 +14,7 @@ has _util => ( isa => 'Gitalist::Git::Util',
                is => 'ro',
                lazy_build => 1,
                handles => [ 'run_cmd',
+                            'run_cmd_fh',
                             'run_cmd_list',
                             'get_gpp_object',
                             'gpp',
index bec7c03..154f012 100644 (file)
@@ -13,6 +13,7 @@ class Gitalist::Git::Object {
                      weak_ref => 1,
                      handles => {
                          _run_cmd => 'run_cmd',
+                         _run_cmd_fh => 'run_cmd_fh',
                          _run_cmd_list => 'run_cmd_list',
                          _get_gpp_object => 'get_gpp_object',
                      },
index d42e41b..5a125f6 100644 (file)
@@ -44,7 +44,7 @@ class Gitalist::Git::Object::Commit
                     ? '--cc' : '--root';
                 push @cmd, $self->sha1;
             }
-            return $self->_run_cmd( @cmd );
+            return $self->_run_cmd_fh( @cmd );
         }
 
         method diff ( Maybe[Bool] :$patch?,
index 988ed03..4ce5bb3 100644 (file)
@@ -46,6 +46,17 @@ EOR
         return $out;
     }
 
+    method run_cmd_fh (@args) {
+        unshift @args, ('--git-dir' => $self->gitdir)
+            if $self->has_project;
+        run [$self->_git, @args],
+            '<pipe', \*IN,
+            '>pipe', \*OUT,
+            '2>pipe', \*ERR
+                or die "cmd returned *?";
+        return \*OUT;
+    }
+
     method run_cmd_list (@args) {
         my $cmdout = $self->run_cmd(@args);
         return $cmdout ? split(/\n/, $cmdout) : ();