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>
This commit is contained in:
Mike Frysinger 2021-02-16 15:45:19 -05:00
parent 5d9c4972e0
commit c5bbea8db3

View File

@ -352,6 +352,11 @@ class GitCommand(object):
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 @@ class GitCommand(object):
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