<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -7,6 +7,7 @@ Echoe.new('gash') do |p|
   p.email = &quot;judofyr@gmail.com&quot;
   p.summary = &quot;Git + Hash&quot;
   p.url = &quot;http://dojo.rubyforge.org/gash/&quot;
+  p.runtime_dependencies = [&quot;open4 &gt;= 0.9.6&quot;]
   p.rdoc_options += [&quot;--main&quot;, &quot;Gash&quot;, &quot;--title&quot;, &quot;Gash&quot;]
 end
 </diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'delegate'
+require 'open4'
 
 # == What is Gash?
 #
@@ -381,7 +382,7 @@ class Gash &lt; SimpleDelegator
   
   # Checks if the current branch exists
   def branch_exists?
-    git('rev-parse', @branch, '2&gt;&amp;1')
+    git('rev-parse', @branch)
     true
   rescue Errors::Git
     false
@@ -438,13 +439,13 @@ class Gash &lt; SimpleDelegator
   end
   
   def git_tree(&amp;blk)
-    git('ls-tree', '-r', '-t', '-z', @branch, '2&gt;&amp;1').split(&quot;\0&quot;).each(&amp;blk)
+    git('ls-tree', '-r', '-t', '-z', @branch).split(&quot;\0&quot;).each(&amp;blk)
   rescue Errors::Git
     &quot;&quot;
   end
   
   def git_tree_sha1(from = @branch)
-    git('rev-parse', @branch + '^{tree}', '2&gt;&amp;1')
+    git('rev-parse', @branch + '^{tree}')
   rescue Errors::Git
   end
   
@@ -472,10 +473,10 @@ class Gash &lt; SimpleDelegator
   # ==== Returns
   # String:: if you didn't supply a block, the things git said on STDOUT, otherwise noting
   def git(cmd, *rest, &amp;block)
-    result, status = run_git(cmd, *rest, &amp;block)
+    result, reserr, status = run_git(cmd, *rest, &amp;block)
 
     if status != 0
-      raise Errors::Git.new(&quot;Error: #{cmd} returned #{status}. Result: #{result}&quot;)
+      raise Errors::Git.new(&quot;Error: #{cmd} returned #{status}. STDERR: #{reserr}&quot;)
     end
     result
   end
@@ -491,7 +492,7 @@ class Gash &lt; SimpleDelegator
   # ==== Returns
   # Integer:: the return status of git
   def git_status(cmd, *rest, &amp;block)
-    run_git(cmd, *rest, &amp;block)[1]
+    run_git(cmd, *rest, &amp;block)[2]
   end
 
   # passes the command over to git (you should not call this directly)
@@ -503,44 +504,53 @@ class Gash &lt; SimpleDelegator
   #
   # ==== Options
   # :strip&lt;Boolean&gt;:: true to strip the output String#strip, false not to to it
+  # :git_dir&lt;Boolean&gt;:: true to automatically use @repository as git-dir, false to not use anything.
   #
   # ==== Raises
   # Errors::Git:: if git returns non-null, an Exception is raised
   #
   # ==== Returns
-  # Array[String, Integer]:: the first item is the STDOUT of git, the second is the return-status
+  # Array[String, String, Integer]:: the first item is the STDOUT of git, the second is the STDERR, the third is the return-status
   def run_git(cmd, *args, &amp;block)
     options = if args.last.kind_of?(Hash)
       args.pop
     else
       {}
     end
-
     options[:strip] = true unless options.key?(:strip)
+    
+    git_cmd = [&quot;git&quot;]
+    
+    unless options[:git_dir] == false
+      git_cmd.push(&quot;--git-dir&quot;, @repository)
+    end
 
-    ENV[&quot;GIT_DIR&quot;] = @repository
-    cmd = &quot;git #{cmd} #{args.join(' ')}&quot;
-
+    git_cmd.push(cmd, *args)
+    
     result = &quot;&quot;
-    IO.popen(cmd, &quot;w+&quot;) do |f|
+    reserr = &quot;&quot;
+    status = Open4.popen4(*git_cmd) do |pid, stdin, stdout, stderr|
       if input = options.delete(:input)
-        f.write(input)
-        f.close_write
+        stdin.write(input)
       elsif block_given?
-        yield f
-        f.close_write
+        yield stdin
       end
+      stdin.close_write
 
       result = &quot;&quot;
+      reserr = &quot;&quot;
 
-      while !f.eof
-        result &lt;&lt; f.read
+      while !stdout.eof
+        result &lt;&lt; stdout.read
+      end
+      
+      while !stderr.eof
+        reserr &lt;&lt; stderr.read
       end
     end
-    status = $?
 
     result.strip! if options[:strip] == true
-
-    [result, status]
+    
+    [result, reserr, status]
   end
 end
\ No newline at end of file</diff>
      <filename>lib/gash.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b307b9c147491e13069099a09bfa63f095d3d642</id>
    </parent>
  </parents>
  <author>
    <name>Magnus Holm</name>
    <email>judofyr@gmail.com</email>
  </author>
  <url>http://github.com/judofyr/gash/commit/04860c3a4cba3f895aabb2b71c6019c09e8ddf8f</url>
  <id>04860c3a4cba3f895aabb2b71c6019c09e8ddf8f</id>
  <committed-date>2008-09-30T13:02:30-07:00</committed-date>
  <authored-date>2008-09-30T12:50:35-07:00</authored-date>
  <message>Switching to Open4. Much more robust handling of running the git-command.</message>
  <tree>0bf7b5275fcf9913be126020c62ff5447364b444</tree>
  <committer>
    <name>Magnus Holm</name>
    <email>judofyr@gmail.com</email>
  </committer>
</commit>
