threads / patch / 15832

patch, 2 partsHandle "git diff-tree --stdin" error

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

## tl;dr

2 messages between Oct 9, 2008 and Oct 9, 2008. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Samuel Tardieu· Oct 9, 2008, 09:01 UTC · lore

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(-)
Show changes to stgit/lib/git.py +3 −3
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):
Samuel Tardieu· Oct 9, 2008, 09:02 UTC · re: Samuel Tardieu · lore

[StGit PATCH 2/2] Always resolve "git describe" to something

Sometimes, "git describe" cannot describe the current version. Use
"--always" so that we have a fallback.
---
 stgit/version.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to stgit/version.py +1 −1
diff --git a/stgit/version.py b/stgit/version.py
index d57053d..05fa8e9 100644
--- a/stgit/version.py
+++ b/stgit/version.py
@@ -8,7 +8,7 @@ class VersionUnavailable(StgException):
 def git_describe_version():
     path = sys.path[0]
     try:
-        v = run.Run('git', 'describe', '--tags', '--abbrev=4'
+        v = run.Run('git', 'describe', '--tags', '--abbrev=4', '--always'
                     ).cwd(path).output_one_line()
     except run.RunException, e:
         raise VersionUnavailable(str(e))

← back to recent threads