@@ -83,7 +83,7 @@ def _set_cache_(self, attr):
8383 # prepare our data lines to match rev-list
8484 data_lines = self .data .splitlines ()
8585 data_lines .insert (0 , "commit %s" % self .id )
86- temp = self ._iter_from_process_or_stream (self .repo , iter (data_lines )).next ()
86+ temp = self ._iter_from_process_or_stream (self .repo , iter (data_lines ), False ).next ()
8787 self .parents = temp .parents
8888 self .tree = temp .tree
8989 self .author = temp .author
@@ -111,7 +111,8 @@ def count(self, paths='', **kwargs):
111111 to commits actually containing the paths
112112
113113 ``kwargs``
114- Additional options to be passed to git-rev-list
114+ Additional options to be passed to git-rev-list. They must not alter
115+ the ouput style of the command, or parsing will yield incorrect results
115116 Returns
116117 int
117118 """
@@ -144,9 +145,8 @@ def iter_items(cls, repo, rev, paths='', **kwargs):
144145 options = {'pretty' : 'raw' , 'as_process' : True }
145146 options .update (kwargs )
146147
147- # the test system might confront us with string values -
148148 proc = repo .git .rev_list (rev , '--' , paths , ** options )
149- return cls ._iter_from_process_or_stream (repo , proc )
149+ return cls ._iter_from_process_or_stream (repo , proc , True )
150150
151151 def iter_parents (self , paths = '' , ** kwargs ):
152152 """
@@ -191,7 +191,7 @@ def stats(self):
191191 return stats .Stats ._list_from_string (self .repo , text )
192192
193193 @classmethod
194- def _iter_from_process_or_stream (cls , repo , proc_or_stream ):
194+ def _iter_from_process_or_stream (cls , repo , proc_or_stream , from_rev_list ):
195195 """
196196 Parse out commit information into a list of Commit objects
197197
@@ -201,17 +201,20 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
201201 ``proc``
202202 git-rev-list process instance (raw format)
203203
204+ ``from_rev_list``
205+ If True, the stream was created by rev-list in which case we parse
206+ the message differently
204207 Returns
205208 iterator returning Commit objects
206209 """
207210 stream = proc_or_stream
208211 if not hasattr (stream ,'next' ):
209212 stream = proc_or_stream .stdout
210213
211-
212214 for line in stream :
213- id = line .split ()[1 ]
214- assert line .split ()[0 ] == "commit"
215+ commit_tokens = line .split ()
216+ id = commit_tokens [1 ]
217+ assert commit_tokens [0 ] == "commit"
215218 tree = stream .next ().split ()[1 ]
216219
217220 parents = []
@@ -231,13 +234,20 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
231234 stream .next ()
232235
233236 message_lines = []
234- next_line = None
235- for msg_line in stream :
236- if not msg_line .startswith (' ' ):
237- break
238- # END abort message reading
239- message_lines .append (msg_line .strip ())
240- # END while there are message lines
237+ if from_rev_list :
238+ for msg_line in stream :
239+ if not msg_line .startswith (' ' ):
240+ # and forget about this empty marker
241+ break
242+ # END abort message reading
243+ # strip leading 4 spaces
244+ message_lines .append (msg_line [4 :])
245+ # END while there are message lines
246+ else :
247+ # a stream from our data simply gives us the plain message
248+ for msg_line in stream :
249+ message_lines .append (msg_line )
250+ # END message parsing
241251 message = '\n ' .join (message_lines )
242252
243253 yield Commit (repo , id = id , parents = tuple (parents ), tree = tree , author = author , authored_date = authored_date ,
0 commit comments