From: Karl Hasselström Date: Thu, 6 Sep 2007 23:31:22 +0000 (+0200) Subject: Discard stderr when determining if a patch is already applied X-Git-Tag: v0.14~96 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/5dfab1742228a9fd237cc124943fcab6d7e9b40a Discard stderr when determining if a patch is already applied An error from git-apply just means that the patch isn't applied. Signed-off-by: Karl Hasselström --- diff --git a/stgit/git.py b/stgit/git.py index f847cce..181e10d 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -628,7 +628,8 @@ def apply_diff(rev1, rev2, check_index = True, files = None): diff_str = diff(files, rev1, rev2) if diff_str: try: - GRun('git-apply', *index_opt).raw_input(diff_str).no_output() + GRun('git-apply', *index_opt).raw_input( + diff_str).discard_stderr().no_output() except GitRunException: return False diff --git a/stgit/run.py b/stgit/run.py index 29f8f71..7986f3b 100644 --- a/stgit/run.py +++ b/stgit/run.py @@ -43,6 +43,7 @@ class Run: self.__good_retvals = [0] self.__env = None self.__indata = None + self.__discard_stderr = False def __log_start(self): if _log_mode == 'debug': out.start('Running subprocess %s' % self.__cmd) @@ -65,11 +66,14 @@ class Run: try: p = subprocess.Popen(self.__cmd, env = self.__env, stdin = subprocess.PIPE, - stdout = subprocess.PIPE) + stdout = subprocess.PIPE, + stderr = subprocess.PIPE) outdata, errdata = p.communicate(self.__indata) self.exitcode = p.returncode except OSError, e: raise self.exc('%s failed: %s' % (self.__cmd[0], e)) + if errdata and not self.__discard_stderr: + out.err_raw(errdata) self.__log_end(self.exitcode) self.__check_exitcode() return outdata @@ -87,6 +91,9 @@ class Run: def returns(self, retvals): self.__good_retvals = retvals return self + def discard_stderr(self, discard = True): + self.__discard_stderr = discard + return self def env(self, env): self.__env = dict(os.environ) self.__env.update(env)