@@ -57,12 +57,12 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
5757 __slots__ = ("tree" ,
5858 "author" , "authored_date" , "author_tz_offset" ,
5959 "committer" , "committed_date" , "committer_tz_offset" ,
60- "message" , "parents" , "encoding" )
60+ "message" , "parents" , "encoding" , "gpgsig" )
6161 _id_attribute_ = "binsha"
6262
6363 def __init__ (self , repo , binsha , tree = None , author = None , authored_date = None , author_tz_offset = None ,
6464 committer = None , committed_date = None , committer_tz_offset = None ,
65- message = None , parents = None , encoding = None ):
65+ message = None , parents = None , encoding = None , gpgsig = None ):
6666 """Instantiate a new Commit. All keyword arguments taking None as default will
6767 be implicitly set on first query.
6868
@@ -120,6 +120,7 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
120120 self .parents = parents
121121 if encoding is not None :
122122 self .encoding = encoding
123+ self .gpgsig = gpgsig
123124
124125 @classmethod
125126 def _get_intermediate_items (cls , commit ):
@@ -393,6 +394,12 @@ def _serialize(self, stream):
393394
394395 if self .encoding != self .default_encoding :
395396 write ("encoding %s\n " % self .encoding )
397+
398+ if self .gpgsig :
399+ write ("gpgsig" )
400+ for sigline in self .gpgsig .split ("\n " ):
401+ write (" " + sigline + "\n " )
402+
396403
397404 write ("\n " )
398405
@@ -430,13 +437,28 @@ def _deserialize(self, stream):
430437 # message.
431438 self .encoding = self .default_encoding
432439 # read encoding or empty line to separate message
433- enc = readline ()
434- enc = enc .strip ()
435- if enc :
436- self .encoding = enc [enc .find (' ' )+ 1 :]
437- # now comes the message separator
438- readline ()
439- # END handle encoding
440+
441+ # read headers
442+ buf = readline ().strip ()
443+ while buf != "" :
444+ if buf [0 :10 ] == "encoding " :
445+ self .encoding = buf [buf .find (' ' )+ 1 :]
446+ elif buf [0 :7 ] == "gpgsig " :
447+ sig = buf [buf .find (' ' )+ 1 :] + "\n "
448+ is_next_header = False
449+ while True :
450+ sigbuf = readline ()
451+ if sigbuf == "" : break
452+ if sigbuf [0 :1 ] != " " :
453+ buf = sigbuf .strip ()
454+ is_next_header = True
455+ break
456+ sig += sigbuf [1 :]
457+ self .gpgsig = sig
458+ if is_next_header :
459+ continue
460+ buf = readline ().strip ()
461+
440462
441463 # decode the authors name
442464 try :
0 commit comments