git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Tardieu <sam@rfc1149.net>
To: git@vger.kernel.org
Subject: [StGit PATCH 1/2] Handle "git diff-tree --stdin" error
Date: Thu, 09 Oct 2008 11:01:57 +0200	[thread overview]
Message-ID: <20081009090157.12637.45887.stgit@arrakis.enst.fr> (raw)

If, for any reason, one of the SHA1 is not a commit object,
"git diff-tree --stdin" will signal an error on its standard
error and will only issue the requested "end" pattern.

"stg diff" could wait forver for the right references to
happen. With this patch, we now get:

% stg diff
stg diff: error: Object 6daaab2215a3d277a315d6938bdda86b2f75f6af not a commit
---
 stgit/lib/git.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 4f210f8..45c0b32 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -579,10 +579,10 @@ class DiffTreeProcesses(object):
         p.stdin.write(query + end)
         p.stdin.flush()
         s = ''
-        while not (s.endswith('\n' + end) or s.endswith('\0' + end)):
+        while not s.endswith(end):
             s += os.read(p.stdout.fileno(), 4096)
-        assert s.startswith(query)
-        assert s.endswith(end)
+        if not s.startswith(query):
+            raise RepositoryException(os.read(p.stderr.fileno(), 4096))
         return s[len(query):-len(end)]
 
 class Repository(RunWithEnv):

             reply	other threads:[~2008-10-09  9:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09  9:01 Samuel Tardieu [this message]
2008-10-09  9:02 ` [StGit PATCH 2/2] Always resolve "git describe" to something Samuel Tardieu

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

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

  git send-email \
    --in-reply-to=20081009090157.12637.45887.stgit@arrakis.enst.fr \
    --to=sam@rfc1149.net \
    --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.
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 NNTP newsgroup(s).