@@ -7,7 +7,8 @@ test_expect_success PERL 'setup' '
77 mkdir dir &&
88 echo parent > dir/foo &&
99 echo dummy > bar &&
10- git add bar dir/foo &&
10+ echo committed > HEAD &&
11+ git add bar dir/foo HEAD &&
1112 git commit -m initial &&
1213 test_tick &&
1314 test_commit second dir/foo head &&
@@ -17,47 +18,57 @@ test_expect_success PERL 'setup' '
1718 save_head
1819'
1920
20- # note: bar sorts before dir, so the first 'n' is always to skip ' bar'
21+ # note: order of files with unstaged changes: HEAD bar dir/foo
2122
2223test_expect_success PERL ' saying "n" does nothing' '
24+ set_state HEAD HEADfile_work HEADfile_index &&
2325 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
26+ (echo n; echo n; echo n) | test_must_fail git stash save -p &&
27+ verify_state HEAD HEADfile_work HEADfile_index &&
28+ verify_saved_state bar &&
29+ verify_state dir/foo work index
2730'
2831
2932test_expect_success PERL ' git stash -p' '
30- (echo n; echo y) | git stash save -p &&
31- verify_state dir/foo head index &&
33+ (echo y; echo n; echo y) | git stash save -p &&
34+ verify_state HEAD committed HEADfile_index &&
3235 verify_saved_state bar &&
36+ verify_state dir/foo head index &&
3337 git reset --hard &&
3438 git stash apply &&
35- verify_state dir/foo work head &&
36- verify_state bar dummy dummy
39+ verify_state HEAD HEADfile_work committed &&
40+ verify_state bar dummy dummy &&
41+ verify_state dir/foo work head
3742'
3843
3944test_expect_success PERL ' git stash -p --no-keep-index' '
40- set_state dir/foo work index &&
45+ set_state HEAD HEADfile_work HEADfile_index &&
4146 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 &&
47+ set_state dir/foo work index &&
48+ (echo y; echo n; echo y) | git stash save -p --no-keep-index &&
49+ verify_state HEAD committed committed &&
4450 verify_state bar bar_work dummy &&
51+ verify_state dir/foo head head &&
4552 git reset --hard &&
4653 git stash apply --index &&
47- verify_state dir/foo work index &&
48- verify_state bar dummy bar_index
54+ verify_state HEAD HEADfile_work HEADfile_index &&
55+ verify_state bar dummy bar_index &&
56+ verify_state dir/foo work index
4957'
5058
5159test_expect_success PERL ' git stash --no-keep-index -p' '
52- set_state dir/foo work index &&
60+ set_state HEAD HEADfile_work HEADfile_index &&
5361 set_state bar bar_work bar_index &&
54- (echo n; echo y) | git stash save --no-keep-index -p &&
62+ set_state dir/foo work index &&
63+ (echo y; echo n; echo y) | git stash save --no-keep-index -p &&
64+ verify_state HEAD committed committed &&
5565 verify_state dir/foo head head &&
5666 verify_state bar bar_work dummy &&
5767 git reset --hard &&
5868 git stash apply --index &&
59- verify_state dir/foo work index &&
60- verify_state bar dummy bar_index
69+ verify_state HEAD HEADfile_work HEADfile_index &&
70+ verify_state bar dummy bar_index &&
71+ verify_state dir/foo work index
6172'
6273
6374test_expect_success PERL ' none of this moved HEAD' '
0 commit comments