Print git output when git push fails.

In the manage_projects.py script print the captured git output when git
push fails.

Change-Id: I77d8b7e926b6b23b4727a1856a79146daa9d6381
Reviewed-on: https://review.openstack.org/16137
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
diff --git a/manage_projects.py b/manage_projects.py
index cf88fb3..4ef8a70 100755
--- a/manage_projects.py
+++ b/manage_projects.py
@@ -81,6 +81,13 @@
     return status
 
 
+def git_command_output(repo_dir, sub_cmd, env={}):
+    git_dir = os.path.join(repo_dir, '.git')
+    cmd = "git --git-dir=%s --work-tree=%s %s" % (git_dir, repo_dir, sub_cmd)
+    status, out = run_command(cmd, True, env)
+    return (status, out)
+
+
 def fetch_config(project, remote_url, repo_path, env={}):
     status = git_command(repo_path, "fetch %s +refs/meta/config:"
                          "refs/remotes/gerrit-meta/config" % remote_url, env)
@@ -119,11 +126,12 @@
     if status != 0:
         print "Failed to commit config for project: %s" % project
         return False
-    status = git_command(repo_path,
+    status, out = git_command_output(repo_path,
                          "push %s HEAD:refs/meta/config" %
                          remote_url, env)
     if status != 0:
         print "Failed to push config for project: %s" % project
+        print out
         return False
     return True