From a7a9ceb771b2bff6948b27547d3e0b93450de9c0 Mon Sep 17 00:00:00 2001 From: Robert Iannucci Date: Thu, 16 Feb 2017 17:38:06 -0800 Subject: [PATCH] [gclient] _Capture to optionally not strip output. BUG=693030 Change-Id: Ic85a989fc68ec171bfef6b12dfc8b68cf2c5b77c Reviewed-on: https://chromium-review.googlesource.com/444156 Reviewed-by: Aaron Gable Reviewed-by: Sergey Berezin Commit-Queue: Robbie Iannucci --- gclient_scm.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index c6d7699ce6..bb1b1a2110 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -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.