Skip to content

Commit f3217e2

Browse files
committed
t3701: Editing a split hunk in an "add -p" session
Arnaud Lacombe reported that with the recent change to reject overlapping hunks fed to "git apply", the edit mode of an "add -p" session that lazily feeds overlapping hunks without coalescing adjacent ones claim that the patch does not apply. Expose the problem to be fixed. Cf. http://thread.gmane.org/gmane.comp.version-control.git/170685/focus=171000 Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5ea3f2 commit f3217e2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

t/t3701-add-interactive.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,40 @@ test_expect_success PERL 'deleting an empty file' '
295295
test_cmp expected diff
296296
'
297297

298+
test_expect_success PERL 'split hunk setup' '
299+
git reset --hard &&
300+
for i in 10 20 30 40 50 60
301+
do
302+
echo $i
303+
done >test &&
304+
git add test &&
305+
test_tick &&
306+
git commit -m test &&
307+
308+
for i in 10 15 20 21 22 23 24 30 40 50 60
309+
do
310+
echo $i
311+
done >test
312+
'
313+
314+
test_expect_failure PERL 'split hunk "add -p (edit)"' '
315+
# Split, say Edit and do nothing. Then:
316+
#
317+
# 1. Broken version results in a patch that does not apply and
318+
# only takes [y/n] (edit again) so the first q is discarded
319+
# and then n attempts to discard the edit. Repeat q enough
320+
# times to get out.
321+
#
322+
# 2. Correct version applies the (not)edited version, and asks
323+
# about the next hunk, against wich we say q and program
324+
# exits.
325+
for a in s e q n q q
326+
do
327+
echo $a
328+
done |
329+
EDITOR=: git add -p &&
330+
git diff >actual &&
331+
! grep "^+15" actual
332+
'
333+
298334
test_done

0 commit comments

Comments
 (0)