def command(cmd, args, io_in, io_out, dir = nil)
      cmd = [git_path, cmd] + args
      opts = {:err => :close}
      opts[:chdir] = dir unless dir.nil?
      cmd << opts
      IO.popen(cmd, 'r+b') do |pipe|
        while ! io_in.nil? && chunk = io_in.read(READ_SIZE) do
          pipe.write(chunk)
        end
        pipe.close_write
        while chunk = pipe.read(READ_SIZE) do
          io_out.write(chunk) unless io_out.nil?
        end
      end
    end
def command(cmd, args, io_in, io_out, dir = nil)
      cmd = [git_path, cmd] + args
      opts = {:err => :close}
      opts[:chdir] = dir unless dir.nil?
      cmd << opts
      IO.popen(cmd, 'r+b') do |pipe|
        while ! io_in.nil? && chunk = io_in.read(READ_SIZE) do
          pipe.write(chunk)
        end
        pipe.close_write
        while chunk = pipe.read(READ_SIZE) do
          io_out.write(chunk) unless io_out.nil?
        end
      end
    end
Runs the Git utilty with the given subcommand.

 @param [String] cmd the Git subcommand to invoke.
 @param [Array<String>] args additional arguments for the command.
 @param [#read, nil] io_in a readable, IO-like source of data to write to
   the Git command.
 @param [#write, nil] io_out a writable, IO-like sink for output produced
   by the Git command.
 @param [String, nil] dir a directory to switch to before invoking the Git
   command.