Subject: Re: [PATCH] add -p: coalesce hunks before testing applicability

From: Jochen Sprickerhof <[email-masked]>
Date: Mon, 3 Sep 2018 21:01:14 +0200

Hi Phillip,

* Phillip Wood <[email-masked]> [2018-08-30 14:47]:
>When $newhunk is created it is marked as dirty to prevent 
>coalesce_overlapping_hunks() from coalescing it. This patch does not 
>change that. What is happening is that by calling 
>coalesce_overlapping_hunks() the hunks that are not currently selected 
>are filtered out and any hunks that can be coalesced are (I think that 
>in the test that starts passing with this patch the only change is the 
>filtering as there's only a single hunk selected).

Agreed here. It would be enough to include the first hunk in the test to 
make it fail again. Still I would see the patch as going in the right 
direction as we need something like coalesce_overlapping_hunks() to make 
the hunks applicable after the edit.

>This is a subtle change to the test for the applicability of an edited 
>hunk. Previously when all the hunks were used to create the test patch 
>we could be certain that if the test patch applied then if the user 
>later selected any unselected hunk or deselected any selected hunk 
>then that operation would succeed. I'm not sure that is true now (but 
>I haven't thought about it for very long).

I'm not sure here. If we use the same test from t3701, do s(plit), 
y(es), e(dit), it would fail later on. Can you come up with an example?

> We could restore the old 
>test condition and coalesce the hunks by copying all the hunks and 
>setting $hunk->{USE}=1 when creating the test patch if that turns out 
>to be useful (it would be interesting to see if the test still passes 
>with that change).

We set USE=1 for $newhunk already, or where would you set it?

Cheers Jochen