summaryrefslogtreecommitdiff
path: root/morphlib/git.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-10-29 17:12:15 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-10-29 17:16:41 +0000
commit426526c692fecd520b1946f362e148d043c61441 (patch)
treeff1069aeea1f03a4cfe8233a6aa2def6c05bc9d2 /morphlib/git.py
parent4f959335730d37be8d7cd53a2af668d8887e72cc (diff)
downloadmorph-426526c692fecd520b1946f362e148d043c61441.tar.gz
Echo stderr of subcommands that do network IO when --verbose is used
Morph can appear to hang in situations where it is actually waiting on a slow network operation. This change gives users a way to see the output of the subcommands that are doing the network IO (either 'wget', 'git clone' or 'git remote update'). The status information goes onto stderr, because that is where the subcommands write it. Morph tends to put its status output on stdout, but (a) some commands are machine-parsed, such as `serialise-artifact` and (b) it's tricky to get Git to put status output on stdout.
Diffstat (limited to 'morphlib/git.py')
-rw-r--r--morphlib/git.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/morphlib/git.py b/morphlib/git.py
index d897de3b..70222acb 100644
--- a/morphlib/git.py
+++ b/morphlib/git.py
@@ -22,6 +22,7 @@ import os
import re
import string
import StringIO
+import sys
import time
@@ -333,6 +334,16 @@ def gitcmd(runcmd, *args, **kwargs):
# is enough to say what it contains, so we turn it off by setting
# the right flag in an environment variable.
kwargs['env']['GIT_NO_REPLACE_OBJECTS'] = '1'
+
cmdline = ['git']
+
+ echo_stderr = kwargs.pop('echo_stderr', False)
+ if echo_stderr:
+ if 'stderr' not in kwargs:
+ # Ensure status output is visible. Git will hide it if stderr is
+ # redirected somewhere else (the --progress flag overrides this
+ # behaviour for the 'clone' command, but not others).
+ kwargs['stderr'] = sys.stderr
+
cmdline.extend(args)
return runcmd(cmdline, **kwargs)