]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t3904-stash-patch.sh
3 test_description
='stash -p'
6 if ! test_have_prereq PERL
8 skip_all
='skipping stash -p tests, perl not available'
12 test_expect_success
'setup' '
14 echo parent > dir/foo &&
16 echo committed > HEAD &&
17 git add bar dir/foo HEAD &&
18 git commit -m initial &&
20 test_commit second dir/foo head &&
21 echo index > dir/foo &&
23 set_and_save_state bar bar_work bar_index &&
27 # note: order of files with unstaged changes: HEAD bar dir/foo
29 test_expect_success
'saying "n" does nothing' '
30 set_state HEAD HEADfile_work HEADfile_index &&
31 set_state dir/foo work index &&
32 test_write_lines n n n | test_must_fail git stash save -p &&
33 verify_state HEAD HEADfile_work HEADfile_index &&
34 verify_saved_state bar &&
35 verify_state dir/foo work index
38 test_expect_success
'git stash -p' '
39 test_write_lines y n y | git stash save -p &&
40 verify_state HEAD committed HEADfile_index &&
41 verify_saved_state bar &&
42 verify_state dir/foo head index &&
45 verify_state HEAD HEADfile_work committed &&
46 verify_state bar dummy dummy &&
47 verify_state dir/foo work head
50 test_expect_success
'git stash -p --no-keep-index' '
51 set_state HEAD HEADfile_work HEADfile_index &&
52 set_state bar bar_work bar_index &&
53 set_state dir/foo work index &&
54 test_write_lines y n y | git stash save -p --no-keep-index &&
55 verify_state HEAD committed committed &&
56 verify_state bar bar_work dummy &&
57 verify_state dir/foo head head &&
59 git stash apply --index &&
60 verify_state HEAD HEADfile_work HEADfile_index &&
61 verify_state bar dummy bar_index &&
62 verify_state dir/foo work index
65 test_expect_success
'git stash --no-keep-index -p' '
66 set_state HEAD HEADfile_work HEADfile_index &&
67 set_state bar bar_work bar_index &&
68 set_state dir/foo work index &&
69 test_write_lines y n y | git stash save --no-keep-index -p &&
70 verify_state HEAD committed committed &&
71 verify_state dir/foo head head &&
72 verify_state bar bar_work dummy &&
74 git stash apply --index &&
75 verify_state HEAD HEADfile_work HEADfile_index &&
76 verify_state bar dummy bar_index &&
77 verify_state dir/foo work index
80 test_expect_success
'stash -p --no-keep-index -- <pathspec> does not unstage other files' '
81 set_state HEAD HEADfile_work HEADfile_index &&
82 set_state dir/foo work index &&
83 echo y | git stash push -p --no-keep-index -- HEAD &&
84 verify_state HEAD committed committed &&
85 verify_state dir/foo work index
88 test_expect_success
'none of this moved HEAD' '
92 test_expect_failure
'stash -p with split hunk' '
100 git commit -m "initial" &&
108 printf "%s\n" s n y q |
109 test_might_fail git stash -p 2>error &&
110 ! test_must_be_empty error &&
111 grep "added line 1" test &&
112 ! grep "added line 2" test