Commit a7a9ceb7 authored by Robert Iannucci's avatar Robert Iannucci Committed by Commit Bot

[gclient] _Capture to optionally not strip output.

BUG=693030

Change-Id: Ic85a989fc68ec171bfef6b12dfc8b68cf2c5b77c
Reviewed-on: https://chromium-review.googlesource.com/444156Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
Reviewed-by: 's avatarSergey Berezin <sergeyberezin@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
parent c41d8b9c
......@@ -305,14 +305,15 @@ class GitWrapper(SCMWrapper):
# actually in a broken state here. The index will have both 'a' and 'A',
# but only one of them will exist on the disk. To progress, we delete
# everything that status thinks is modified.
for line in self._Capture(['status', '--porcelain']).splitlines():
output = self._Capture(['status', '--porcelain'], strip=False)
for line in output.splitlines():
# --porcelain (v1) looks like:
# XY filename
try:
filename = line[3:]
self.Print('_____ Deleting residual after reset: %r.' % filename)
gclient_utils.rm_file_or_tree(
os.path.join(self.checkout_path, line[3:]))
os.path.join(self.checkout_path, filename))
except OSError:
pass
......@@ -1120,8 +1121,12 @@ class GitWrapper(SCMWrapper):
def _Capture(self, args, **kwargs):
kwargs.setdefault('cwd', self.checkout_path)
kwargs.setdefault('stderr', subprocess2.PIPE)
strip = kwargs.pop('strip', True)
env = scm.GIT.ApplyEnvVars(kwargs)
return subprocess2.check_output(['git'] + args, env=env, **kwargs).strip()
ret = subprocess2.check_output(['git'] + args, env=env, **kwargs)
if strip:
ret = ret.strip()
return ret
def _Checkout(self, options, ref, force=False, quiet=None):
"""Performs a 'git-checkout' operation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment