Skip to content

Commit acfa161

Browse files
committed
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 <[email protected]>
1 parent 2e697ce commit acfa161

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

t/t3701-add-interactive.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,28 @@ test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
403403
! grep "^+31" actual
404404
'
405405

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+
406428
test_expect_success 'patch mode ignores unmerged entries' '
407429
git reset --hard &&
408430
test_commit conflict &&

0 commit comments

Comments
 (0)