[PATCH] Add a subject indicating that the commit message is empty
Lukas Fleischer
cgit at cryptocrack.de
Thu Aug 11 00:26:22 CEST 2011
On Thu, Aug 11, 2011 at 12:24:04AM +0200, Lukas Fleischer wrote:
> On Thu, Aug 11, 2011 at 01:08:40AM +0300, Nezmer wrote:
> > Before this patch:
> > If the commit message is empty, we would have this html:
> > <a href='path'></a>
> >
> > It's impossible to go to the commit page without viewing the source or
> > using hints (e.g vimperator).
> >
> > After applying this patch:
> > A gitweb-like "(no commit message)" would be displayed as a commit
> > subject.
> >
> > Signed-off-by: Nezmer <git at nezmer.info>
> > ---
> > parsing.c | 5 +++++
> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/parsing.c b/parsing.c
> > index 602e3de..e96a325 100644
> > --- a/parsing.c
> > +++ b/parsing.c
> > @@ -200,6 +200,11 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
> > } else
> > ret->subject = xstrdup(p);
> >
> > + if (!strlen(ret->subject)) {
>
> Using "ret->subject[0] == '\0'" or "*(ret->subject) == '\0'" might be
> slightly faster here.
>
> > + ret->subject = xmalloc(20);
>
> xstrdup already allocates memory. No need to invoke malloc here (doing
> this will result in a memory leak).
Oh, and you obviously also introduce a memory leak by overwriting the
pointer stored in "ret->subject" before without free'ing it. This should
be implemented slightly differently. The idea sounds good, though. I'll
have a look at that.
>
> > + ret->subject = xstrdup("(no commit message)");
> > + }
> > +
> > reencode(&ret->author, ret->msg_encoding, PAGE_ENCODING);
> > reencode(&ret->author_email, ret->msg_encoding, PAGE_ENCODING);
> > reencode(&ret->committer, ret->msg_encoding, PAGE_ENCODING);
> > --
> > 1.7.6
> >
> >
> > _______________________________________________
> > cgit mailing list
> > cgit at hjemli.net
> > http://hjemli.net/mailman/listinfo/cgit
>
> _______________________________________________
> cgit mailing list
> cgit at hjemli.net
> http://hjemli.net/mailman/listinfo/cgit
More information about the CGit
mailing list