[GitPython] Fix crashing w/ "LookupError: unknown encoding: object" as downstream, cleanups
Dennis Gilmore
ausil at fedoraproject.org
Sat Dec 7 09:27:53 UTC 2013
commit 47eb31fc7553dc8409adbe9482128e8450a4a4c8
Author: Igor Gnatenko <i.gnatenko.brain at gmail.com>
Date: Sun Sep 22 20:56:32 2013 +0400
Fix crashing w/ "LookupError: unknown encoding: object" as downstream, cleanups
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1010706
Signed-off-by: Igor Gnatenko <i.gnatenko.brain at gmail.com>
0001-GPG-signature-support-on-commit-object.patch | 73 +++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/0001-GPG-signature-support-on-commit-object.patch b/0001-GPG-signature-support-on-commit-object.patch
new file mode 100644
index 0000000..60ff4e0
--- /dev/null
+++ b/0001-GPG-signature-support-on-commit-object.patch
@@ -0,0 +1,73 @@
+diff -uNr GitPython-0.3.2.RC1.orig/git/objects/commit.py GitPython-0.3.2.RC1/git/objects/commit.py
+--- GitPython-0.3.2.RC1.orig/git/objects/commit.py 2011-06-14 02:31:14.000000000 +0400
++++ GitPython-0.3.2.RC1/git/objects/commit.py 2013-12-07 13:19:10.111948329 +0400
+@@ -57,12 +57,12 @@
+ __slots__ = ("tree",
+ "author", "authored_date", "author_tz_offset",
+ "committer", "committed_date", "committer_tz_offset",
+- "message", "parents", "encoding")
++ "message", "parents", "encoding", "gpgsig")
+ _id_attribute_ = "binsha"
+
+ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
+ committer=None, committed_date=None, committer_tz_offset=None,
+- message=None, parents=None, encoding=None):
++ message=None, parents=None, encoding=None, gpgsig=None):
+ """Instantiate a new Commit. All keyword arguments taking None as default will
+ be implicitly set on first query.
+
+@@ -120,6 +120,7 @@
+ self.parents = parents
+ if encoding is not None:
+ self.encoding = encoding
++ self.gpgsig = gpgsig
+
+ @classmethod
+ def _get_intermediate_items(cls, commit):
+@@ -394,6 +395,11 @@
+ if self.encoding != self.default_encoding:
+ write("encoding %s\n" % self.encoding)
+
++ if self.gpgsig:
++ write("gpgsig")
++ for sigline in self.gpgsig.rstrip("\n").split("\n"):
++ write(" "+sigline+"\n")
++
+ write("\n")
+
+ # write plain bytes, be sure its encoded according to our encoding
+@@ -429,14 +435,26 @@
+ # now we can have the encoding line, or an empty line followed by the optional
+ # message.
+ self.encoding = self.default_encoding
+- # read encoding or empty line to separate message
+- enc = readline()
+- enc = enc.strip()
+- if enc:
+- self.encoding = enc[enc.find(' ')+1:]
+- # now comes the message separator
+- readline()
+- # END handle encoding
++ # read headers
++ buf = readline().strip()
++ while buf != "":
++ if buf[0:10] == "encoding ":
++ self.encoding = buf[buf.find(' ')+1:]
++ elif buf[0:7] == "gpgsig ":
++ sig = buf[buf.find(' ')+1:] + "\n"
++ is_next_header = False
++ while True:
++ sigbuf = readline()
++ if sigbuf == "": break
++ if sigbuf[0:1] != " ":
++ buf = sigbuf.strip()
++ is_next_header = True
++ break
++ sig += sigbuf[1:]
++ self.gpgsig = sig.rstrip("\n")
++ if is_next_header:
++ continue
++ buf = readline().strip()
+
+ # decode the authors name
+ try:
More information about the scm-commits
mailing list