git_command: make execution synchronous

Every use of GitCommand in the tree just calls Wait as soon as it's
instantiated.  Move the bulk of the logic into the init path to make
the call synchronous to simplify.  We'll cleanup the users of the
Wait API to follup commits -- having this split makes it easier to
track down regressions.

Change-Id: I1e8c519efa912da723749ff7663558c04c1f491c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297244
Reviewed-by: Jonathan Nieder <jrn@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
diff --git a/git_command.py b/git_command.py
index 6e28522..6cb6e0c 100644
--- a/git_command.py
+++ b/git_command.py
@@ -352,6 +352,11 @@
       p.stdin.write(input)
       p.stdin.close()
 
+    try:
+      self.rc = self._CaptureOutput()
+    finally:
+      _remove_ssh_client(p)
+
   @staticmethod
   def _GetBasicEnv():
     """Return a basic env for running git under.
@@ -370,12 +375,7 @@
     return env
 
   def Wait(self):
-    try:
-      p = self.process
-      rc = self._CaptureOutput()
-    finally:
-      _remove_ssh_client(p)
-    return rc
+    return self.rc
 
   def _CaptureOutput(self):
     p = self.process