Re: [PATCH] diff-options: add --stat
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Apr 13, 2006, 18:39 UTC
- Message-ID
- <Pine.LNX.4.64.0604131138080.14565@g5.osdl.org>
- In-Reply-To
- <7v64ld2uyv.fsf@assigned-by-dhcp.cox.net>
On Thu, 13 Apr 2006, Junio C Hamano wrote:
Show 17 quoted lines
>
> I like what this tries to do (as I already said), but there are
> issues with the way it does it; here are some comments.
>
> > +static int fn_diffstat(void *priv, mmbuffer_t *mb, int nbuf)
> > +{
> > +...
> > + for (i = 0; i < nbuf; i++)
> > + if (mb[i].ptr[0] == '+')
> > + x->added++;
> > + else if (mb[i].ptr[0] == '-')
> > + x->deleted++;
> > + return 0;
> > +}
>
> This is broken if you have a hunk that adds, deletes or
> leaves a line that happens to begin with a plus or a minus.I think you can just depend on it being in mb[0].ptr[0], no?
xdiff always gives full lines at a time, afaik, and mb[0] always ends up being available.
Linus