git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Jeff KingNext: Junio C Hamano
Message 4 of 6 in “git add -p: demonstrate failure when staging both mode and hunk”
  1. git add -p: demonstrate failure when staging both mode and hunkKirill Smelkov, Aug 15, 2009
  2. add -p: do not attempt to coalesce mode changesThomas Rast, Aug 15, 2009
  3. Jeff KingAug 15, 2009
  4. Thomas RastAug 15, 2009
  5. Junio C HamanoAug 15, 2009
  6. Kirill SmelkovAug 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.