git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGit PATCH 1/2] Handle "git diff-tree --stdin" error

From
Samuel Tardieu <sam@rfc1149.net>
Date
Oct 9, 2008, 09:01 UTC
Message-ID
<20081009090157.12637.45887.stgit@arrakis.enst.fr>

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):
Next: Samuel Tardieu
Message 1 of 2 in “Handle "git diff-tree --stdin" error”
  1. 1/2 Handle "git diff-tree --stdin" errorSamuel Tardieu, Oct 9, 2008
  2. 2/2 Always resolve "git describe" to somethingSamuel Tardieu, Oct 9, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.