Skip to content

Commit cde606c

Browse files
committed
Merge branch 'js/add-i-coalesce-after-editing-hunk' into jch
Applicability check after a patch is edited in a "git add -i/p" session has been improved. * js/add-i-coalesce-after-editing-hunk: add -p: coalesce hunks before testing applicability
2 parents 31e5574 + d4704b0 commit cde606c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

git-add--interactive.perl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,10 +1195,10 @@ sub edit_hunk_loop {
11951195
# delta from the original unedited hunk.
11961196
$hunk->{OFS_DELTA} and
11971197
$newhunk->{OFS_DELTA} += $hunk->{OFS_DELTA};
1198-
if (diff_applies($head,
1199-
@{$hunks}[0..$ix-1],
1200-
$newhunk,
1201-
@{$hunks}[$ix+1..$#{$hunks}])) {
1198+
my @hunk = @{$hunks};
1199+
splice (@hunk, $ix, 1, $newhunk);
1200+
@hunk = coalesce_overlapping_hunks(@hunk);
1201+
if (diff_applies($head, @hunk)) {
12021202
$newhunk->{DISPLAY} = [color_diff(@{$newtext})];
12031203
return $newhunk;
12041204
}

t/t3701-add-interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ test_expect_success 'split hunk "add -p (edit)"' '
391391
! grep "^+15" actual
392392
'
393393

394-
test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
394+
test_expect_success 'split hunk "add -p (no, yes, edit)"' '
395395
test_write_lines 5 10 20 21 30 31 40 50 60 >test &&
396396
git reset &&
397397
# test sequence is s(plit), n(o), y(es), e(dit)

0 commit comments

Comments
 (0)