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 <gitster@pobox.com>
Junio C Hamano committed
Apr 29, 2011 at 12:41 UTC
f3217e2b1791580ce6499b800e93989d312f9718
1 file changed
+36
t/t3701-add-interactive.sh
+36
@@ -295,4 +295,40 @@ test_expect_success PERL 'deleting an empty file' '
295
test_cmp expected diff
296
'
297
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
+
334
test_done