commit: fixup misplacement of --no-post-rewrite description
[gitweb.git] / t / t3701-add-interactive.sh
index fdcbe2e73629fe16bb0d62621b97c624cef5f77c..098a6ae4a086ccfeb8c658a80773eb07c9d66441 100755 (executable)
@@ -294,4 +294,66 @@ test_expect_success PERL 'deleting an empty file' '
        test_cmp expected diff
 '
 
+test_expect_success PERL 'split hunk setup' '
+       git reset --hard &&
+       for i in 10 20 30 40 50 60
+       do
+               echo $i
+       done >test &&
+       git add test &&
+       test_tick &&
+       git commit -m test &&
+
+       for i in 10 15 20 21 22 23 24 30 40 50 60
+       do
+               echo $i
+       done >test
+'
+
+test_expect_success PERL 'split hunk "add -p (edit)"' '
+       # Split, say Edit and do nothing.  Then:
+       #
+       # 1. Broken version results in a patch that does not apply and
+       # only takes [y/n] (edit again) so the first q is discarded
+       # and then n attempts to discard the edit. Repeat q enough
+       # times to get out.
+       #
+       # 2. Correct version applies the (not)edited version, and asks
+       #    about the next hunk, against wich we say q and program
+       #    exits.
+       for a in s e     q n q q
+       do
+               echo $a
+       done |
+       EDITOR=: git add -p &&
+       git diff >actual &&
+       ! grep "^+15" actual
+'
+
+test_expect_success 'patch mode ignores unmerged entries' '
+       git reset --hard &&
+       test_commit conflict &&
+       test_commit non-conflict &&
+       git checkout -b side &&
+       test_commit side conflict.t &&
+       git checkout master &&
+       test_commit master conflict.t &&
+       test_must_fail git merge side &&
+       echo changed >non-conflict.t &&
+       echo y | git add -p >output &&
+       ! grep a/conflict.t output &&
+       cat >expected <<-\EOF &&
+       * Unmerged path conflict.t
+       diff --git a/non-conflict.t b/non-conflict.t
+       index f766221..5ea2ed4 100644
+       --- a/non-conflict.t
+       +++ b/non-conflict.t
+       @@ -1 +1 @@
+       -non-conflict
+       +changed
+       EOF
+       git diff --cached >diff &&
+       test_cmp expected diff
+'
+
 test_done