Re: [PATCH] add -p: do not attempt to coalesce mode changes
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Aug 15, 2009, 14:35 UTC
- Message-ID
- <200908151635.24341.trast@student.ethz.ch>
- In-Reply-To
- <20090815141710.GA15978@sigill.intra.peff.net>
Jeff King wrote:
Show 25 quoted lines
>
> > --- a/git-add--interactive.perl
> > +++ b/git-add--interactive.perl
> > @@ -841,6 +841,10 @@
> > my ($last_o_ctx, $last_was_dirty);
> >
> > for (grep { $_->{USE} } @in) {
> > + if ($_->{TYPE} ne 'hunk') {
> > + push @out, $_;
> > + next;
> > + }
> > my $text = $_->{TEXT};
> > my ($o_ofs) = parse_hunk_header($text->[0]);
> > if (defined $last_o_ctx &&
>
> Hmm. I am not too familiar with the coalesce_overlapping_hunks code, but
> it looks like we peek at $out[-1] based on $last_o_ctx, assuming that
> $last_o_ctx comes from the last hunk pushed (either because we just
> pushed it, or we merged into it). So a non-hunk in the middle of some
> coalescing hunks is going to violate that assumption.
>
> As it is now, I think we always put the 'mode' hunk at the very
> beginning, so that shouldn't happen (and IIRC, that order is preserved
> throughout). So maybe it is not worth worrying about. But an alternate
> patch is below.Hmm. I briefly considered worrying about futureproofing, but then decided it wasn't worth it since we also rely on coalesce_overlapping_hunks only being run over the hunks of a single file. But since you already went to the lengths of doing it, feel free to take the explanation in my commit message and add my Acked-by :-)
--
Thomas Rast
trast@{inf,student}.ethz.ch