Imported Upstream version 2.10.4
[platform/upstream/git.git] / t / t3701-add-interactive.sh
index 24ddd8a..deae948 100755 (executable)
@@ -326,15 +326,34 @@ test_expect_success 'split hunk "add -p (edit)"' '
        # 2. Correct version applies the (not)edited version, and asks
        #    about the next hunk, against which we say q and program
        #    exits.
-       for a in s e     q n q q
-       do
-               echo $a
-       done |
+       printf "%s\n" s e     q n q q |
        EDITOR=: git add -p &&
        git diff >actual &&
        ! grep "^+15" actual
 '
 
+test_expect_failure 'split hunk "add -p (no, yes, edit)"' '
+       cat >test <<-\EOF &&
+       5
+       10
+       20
+       21
+       30
+       31
+       40
+       50
+       60
+       EOF
+       git reset &&
+       # test sequence is s(plit), n(o), y(es), e(dit)
+       # q n q q is there to make sure we exit at the end.
+       printf "%s\n" s n y e   q n q q |
+       EDITOR=: git add -p 2>error &&
+       test_must_be_empty error &&
+       git diff >actual &&
+       ! grep "^+31" actual
+'
+
 test_expect_success 'patch mode ignores unmerged entries' '
        git reset --hard &&
        test_commit conflict &&