@@ -58,12 +58,12 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
5858 __slots__ = ("tree" ,
5959 "author" , "authored_date" , "author_tz_offset" ,
6060 "committer" , "committed_date" , "committer_tz_offset" ,
61- "message" , "parents" , "encoding" )
61+ "message" , "parents" , "encoding" , "gpgsig" )
6262 _id_attribute_ = "binsha"
6363
6464 def __init__ (self , repo , binsha , tree = None , author = None , authored_date = None , author_tz_offset = None ,
6565 committer = None , committed_date = None , committer_tz_offset = None ,
66- message = None , parents = None , encoding = None ):
66+ message = None , parents = None , encoding = None , gpgsig = None ):
6767 """Instantiate a new Commit. All keyword arguments taking None as default will
6868 be implicitly set on first query.
6969
@@ -121,6 +121,8 @@ def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, aut
121121 self .parents = parents
122122 if encoding is not None :
123123 self .encoding = encoding
124+ if gpgsig is not None :
125+ self .gpgsig = gpgsig
124126
125127 @classmethod
126128 def _get_intermediate_items (cls , commit ):
@@ -439,15 +441,29 @@ def _deserialize(self, stream):
439441 # now we can have the encoding line, or an empty line followed by the optional
440442 # message.
441443 self .encoding = self .default_encoding
442- # read encoding or empty line to separate message
444+
445+ # read headers
443446 enc = next_line
444- enc = enc .strip ()
445- if enc :
446- self .encoding = enc [enc .find (' ' )+ 1 :]
447- # now comes the message separator
448- readline ()
449- # END handle encoding
450-
447+ buf = enc .strip ()
448+ while buf != "" :
449+ if buf [0 :10 ] == "encoding " :
450+ self .encoding = buf [buf .find (' ' )+ 1 :]
451+ elif buf [0 :7 ] == "gpgsig " :
452+ sig = buf [buf .find (' ' )+ 1 :] + "\n "
453+ is_next_header = False
454+ while True :
455+ sigbuf = readline ()
456+ if sigbuf == "" : break
457+ if sigbuf [0 :1 ] != " " :
458+ buf = sigbuf .strip ()
459+ is_next_header = True
460+ break
461+ sig += sigbuf [1 :]
462+ self .gpgsig = sig .rstrip ("\n " )
463+ if is_next_header :
464+ continue
465+ buf = readline ().strip ()
466+
451467 # decode the authors name
452468 try :
453469 self .author .name = self .author .name .decode (self .encoding )
0 commit comments