Re: [PATCH] add-interactive: fix bogus diff header line ordering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 22, 2010 at 02:25:19PM -0800, Junio C Hamano wrote:

> Jeff King <peff@xxxxxxxx> writes:
> 
> >  git-add--interactive.perl |   17 ++++++++++++++++-
> >  t/t2016-checkout-patch.sh |    8 ++++++++
> >  2 files changed, 24 insertions(+), 1 deletions(-)
> >
> > diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> > index bfd1003..4173200 100755
> > --- a/git-add--interactive.perl
> > +++ b/git-add--interactive.perl
> > @@ -979,6 +979,21 @@ sub coalesce_overlapping_hunks {
> >  	return @out;
> >  }
> >  
> > +sub reassemble_patch {
> > +	my $head = shift;
> > +	return (
> > +		# Include everything in the header except the beginning of the
> > +		# diff.
> > +		(grep { !/^[-+]{3}/ } @$head),
> > +		# Then include any other non-diff header lines from the hunks.
> > +		(grep { !/^[@ +-]/ } @_),
> > +		# Then begin the diff.
> > +		(grep { /^[-+]{3}/ } @$head),
> > +		# And then the hunk diff lines.
> > +		(grep { /^[@ +-]/ } @_)
> 
> Hmm.  Are you handling "\No newline at the end of the file" correctly?

Nope, good catch. Maybe this should specifically be hoisting known git
header lines back into the header? Or perhaps a better logic would be to
treat each hunk individually, but just take all lines before the "@@"
hunk header? Hmm. I am not sure we would even need to treat hunks
individually...the misplaced header lines should always be part of the
_first_ hunk.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]