[PATCH] Use the first line of commit message in "log --line"

Michael Ellerman michael at ellerman.id.au
Tue May 30 01:25:19 BST 2006


On Tue, 2006-05-30 at 10:07 +1000, Robert Collins wrote:
> On Tue, 2006-05-30 at 09:56 +1000, Michael Ellerman wrote:
> > On 5/30/06, Robert Collins <robertc at robertcollins.net> wrote:
> > >
> > > firstline seems a little overcomplicated. A simpler version:
> > > def firstline(self, string):
> > > # using a type name as a variable name is frowned upon which is why we
> > > # use string, not str
> > >     return "".join(string.splitlines()[:1])
> > 
> > return string.splitlines()[0]  ?
> > 
> > cheers
> > 
> 
> >>> "".splitlines()[0]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> IndexError: list index out of range
> 
> 
> While the message should always have content, its less safe ;)

Ah, weird, splitlines sucks :)

>>> ''.split('\n')[0]
''

cheers

-- 
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person





More information about the bazaar mailing list