t3701: add a test for advanced split-hunk editing
In this developer's workflows, it often happens that a hunk needs to be edited in a way that adds lines, and sometimes even reduces the number of context lines. Let's add a regression test for this. Note that just like the preceding test case, the new test case is *not* handled gracefully by the current `git add -p`. It will be handled correctly by the upcoming built-in `git add -p`, though. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Dec 6, 2019 at 13:08 UTC
0f0fba2cc87219bf0c182201b7798ceb74c24857
1 file changed
+22
t/t3701-add-interactive.sh
+22
@@ -403,6 +403,28 @@ test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
403
! grep "^+31" actual
404
'
405
406
+test_expect_failure 'edit, adding lines to the first hunk' '
407
+ test_write_lines 10 11 20 30 40 50 51 60 >test &&
408
+ git reset &&
409
+ tr _ " " >patch <<-EOF &&
410
+ @@ -1,5 +1,6 @@
411
+ _10
412
+ +11
413
+ +12
414
+ _20
415
+ +21
416
+ +22
417
+ _30
418
+ EOF
419
+ # test sequence is s(plit), e(dit), n(o)
420
+ # q n q q is there to make sure we exit at the end.
421
+ printf "%s\n" s e n q n q q |
422
+ EDITOR=./fake_editor.sh git add -p 2>error &&
423
+ test_must_be_empty error &&
424
+ git diff --cached >actual &&
425
+ grep "^+22" actual
426
+'
427
+
428
test_expect_success 'patch mode ignores unmerged entries' '
429
git reset --hard &&
430
test_commit conflict &&