]>
Commit | Line | Data |
---|---|---|
dda1f2a5 TR |
1 | #!/bin/sh |
2 | ||
3 | test_description='git checkout --patch' | |
4 | . ./lib-patch-mode.sh | |
5 | ||
f2f7b6a5 | 6 | test_expect_success PERL 'setup' ' |
dda1f2a5 TR |
7 | mkdir dir && |
8 | echo parent > dir/foo && | |
9 | echo dummy > bar && | |
44df2e29 JM |
10 | echo committed > HEAD && |
11 | git add bar dir/foo HEAD && | |
dda1f2a5 TR |
12 | git commit -m initial && |
13 | test_tick && | |
14 | test_commit second dir/foo head && | |
15 | echo index > dir/foo && | |
16 | git add dir/foo && | |
17 | set_and_save_state bar bar_work bar_index && | |
18 | save_head | |
19 | ' | |
20 | ||
44df2e29 | 21 | # note: order of files with unstaged changes: HEAD bar dir/foo |
dda1f2a5 | 22 | |
f2f7b6a5 | 23 | test_expect_success PERL 'saying "n" does nothing' ' |
44df2e29 | 24 | set_state HEAD HEADfile_work HEADfile_index && |
a48fcd83 | 25 | set_state dir/foo work index && |
44df2e29 JM |
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 | |
dda1f2a5 TR |
30 | ' |
31 | ||
f2f7b6a5 | 32 | test_expect_success PERL 'git stash -p' ' |
44df2e29 JM |
33 | (echo y; echo n; echo y) | git stash save -p && |
34 | verify_state HEAD committed HEADfile_index && | |
dda1f2a5 | 35 | verify_saved_state bar && |
44df2e29 | 36 | verify_state dir/foo head index && |
dda1f2a5 TR |
37 | git reset --hard && |
38 | git stash apply && | |
44df2e29 JM |
39 | verify_state HEAD HEADfile_work committed && |
40 | verify_state bar dummy dummy && | |
41 | verify_state dir/foo work head | |
dda1f2a5 TR |
42 | ' |
43 | ||
f2f7b6a5 | 44 | test_expect_success PERL 'git stash -p --no-keep-index' ' |
44df2e29 | 45 | set_state HEAD HEADfile_work HEADfile_index && |
dda1f2a5 | 46 | set_state bar bar_work bar_index && |
44df2e29 JM |
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 && | |
dda1f2a5 | 50 | verify_state bar bar_work dummy && |
44df2e29 | 51 | verify_state dir/foo head head && |
dda1f2a5 TR |
52 | git reset --hard && |
53 | git stash apply --index && | |
44df2e29 JM |
54 | verify_state HEAD HEADfile_work HEADfile_index && |
55 | verify_state bar dummy bar_index && | |
56 | verify_state dir/foo work index | |
dda1f2a5 TR |
57 | ' |
58 | ||
3a243f70 | 59 | test_expect_success PERL 'git stash --no-keep-index -p' ' |
44df2e29 | 60 | set_state HEAD HEADfile_work HEADfile_index && |
21ec98a7 | 61 | set_state bar bar_work bar_index && |
44df2e29 JM |
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 && | |
21ec98a7 DM |
65 | verify_state dir/foo head head && |
66 | verify_state bar bar_work dummy && | |
67 | git reset --hard && | |
68 | git stash apply --index && | |
44df2e29 JM |
69 | verify_state HEAD HEADfile_work HEADfile_index && |
70 | verify_state bar dummy bar_index && | |
71 | verify_state dir/foo work index | |
21ec98a7 DM |
72 | ' |
73 | ||
f2f7b6a5 | 74 | test_expect_success PERL 'none of this moved HEAD' ' |
dda1f2a5 TR |
75 | verify_saved_head |
76 | ' | |
77 | ||
78 | test_done |