Improved the GIT_PYTHON_TRACE=full output format
authorSverre Rabbelier <sverre@rabbelier.nl>
Fri, 13 Jun 2008 17:40:14 +0000 (19:40 +0200)
committerSverre Rabbelier <sverre@rabbelier.nl>
Fri, 13 Jun 2008 18:39:52 +0000 (20:39 +0200)
It now also shows stderr if there was any on it, and only
shows stdout if there was any output. Also added a '->'
between the command and the return value as a visual clue.

lib/git/cmd.py

index cf0f066d2e6f7725e7bc70ca413d60aaa05826b1..1eed1f84ed1c140f360e998755d0b897507366b2 100644 (file)
@@ -107,6 +107,10 @@ class Git(MethodMissingMixin):
         status = proc.wait()
         proc.stdout.close()
 
+        if proc.stderr:
+          stderr_value = proc.stderr.read()
+          proc.stderr.close()
+
         # Strip off trailing whitespace by default
         if not with_raw_output:
             stdout_value = stdout_value.rstrip()
@@ -118,7 +122,12 @@ class Git(MethodMissingMixin):
                                   % (str(command), status))
 
         if GIT_PYTHON_TRACE == 'full':
-            print "%s %d: '%s'" % (command, status, stdout_value)
+            if stderr_value:
+              print "%s -> %d: '%s' !! '%s'" % (command, status, stdout_value, stderr_value)
+            elif stdout_value:
+              print "%s -> %d: '%s'" % (command, status, stdout_value)
+            else:
+              print "%s -> %d" % (command, status)
 
         # Allow access to the command's status code
         if with_status: