git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH] Discard stderr when determining if a patch is already applied
Date: Fri, 07 Sep 2007 01:50:48 +0200	[thread overview]
Message-ID: <20070906234906.15591.33653.stgit@yoghurt> (raw)

An error from git-apply just means that the patch isn't applied.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

Somewhere in my subprocess refactoring, the discarding of stderr got
lost. This patch adds it back to the only place I have discovered so
far that actually needs it.

 stgit/git.py |    3 ++-
 stgit/run.py |    9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)


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)

                 reply	other threads:[~2007-09-06 23:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070906234906.15591.33653.stgit@yoghurt \
    --to=kha@treskal.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).