Re: [PATCH] Teach 'git-apply --whitespace=strip' to remove empty lines at the end of file
On 5/20/07, Junio C Hamano <junkio@cox.net> wrote:
Show 34 quoted lines
> "Marco Costalba" <mcostalba@gmail.com> writes:
>
> > Ok. This is take 3. It works correctly on standard patches and also on
> > u0 example that you gave above.
> >
> > This patch is on top of git 1.5.2
> >
> > Please check it.
>
> I think the checks and actions are at the right places (I
> haven't looked very closely nor tried to run it yet).
>
> > builtin-apply.c | 34 ++++++++++++++++++++++++++++++++++
> > 1 files changed, 34 insertions(+), 0 deletions(-)
> >
> > diff --git a/builtin-apply.c b/builtin-apply.c
> > index 0399743..6032f78 100644
> > --- a/builtin-apply.c
> > +++ b/builtin-apply.c
> > ...
> > @@ -1770,6 +1800,10 @@ static int apply_one_fragment(struct buffer_desc *desc,
> > if (match_beginning && offset)
> > offset = -1;
> > if (offset >= 0) {
> > +
> > + if (desc->size - oldsize - offset == 0) /* end of file? */
> > + newsize -= trailing_added_lines;
> > +
> > int diff = newsize - oldsize;
> > unsigned long size = desc->size + diff;
> > unsigned long alloc = desc->alloc;
>
> But we have kept our sources -Wdeclaration-after-statement
> clean so far