3 test_description
='git checkout --patch'
6 test_expect_success
'setup' '
8 echo parent > dir/foo &&
10 git add bar dir/foo &&
11 git commit -m initial &&
13 test_commit second dir/foo head &&
14 echo index > dir/foo &&
16 set_and_save_state bar bar_work bar_index &&
20 # note: bar sorts before dir, so the first 'n' is always to skip 'bar'
22 test_expect_success
'saying "n" does nothing' '
23 set_state dir/foo work index
24 (echo n; echo n) | test_must_fail git stash save -p &&
25 verify_state dir/foo work index &&
26 verify_saved_state bar
29 test_expect_success
'git stash -p' '
30 (echo n; echo y) | git stash save -p &&
31 verify_state dir/foo head index &&
32 verify_saved_state bar &&
35 verify_state dir/foo work head &&
36 verify_state bar dummy dummy
39 test_expect_success
'git stash -p --no-keep-index' '
40 set_state dir/foo work index &&
41 set_state bar bar_work bar_index &&
42 (echo n; echo y) | git stash save -p --no-keep-index &&
43 verify_state dir/foo head head &&
44 verify_state bar bar_work dummy &&
46 git stash apply --index &&
47 verify_state dir/foo work index &&
48 verify_state bar dummy bar_index
51 test_expect_success
'none of this moved HEAD' '