]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t9832-unshelve.sh
3 last_shelved_change
() {
4 p4 changes
-s shelved
-m1 | cut
-d " " -f 2
7 test_description
='git p4 unshelve'
11 test_expect_success
'start p4d' '
15 test_expect_success
'init depot' '
20 p4 submit -d "change 1" &&
23 p4 add file_to_delete &&
24 p4 add file_to_move &&
25 p4 submit -d "add files to delete" &&
26 echo file_to_integrate >file_to_integrate &&
27 p4 add file_to_integrate &&
28 p4 submit -d "add file to integrate"
32 test_expect_success
'initial clone' '
33 git p4 clone --dest="$git" //depot/@all
36 test_expect_success
'create shelved changelist' '
40 echo "a change" >>file1 &&
41 echo "new file" >file2 &&
43 p4 delete file_to_delete &&
44 p4 edit file_to_move &&
45 p4 move file_to_move moved_file &&
46 p4 integrate file_to_integrate integrated_file &&
57 //depot/file_to_delete
60 //depot/integrated_file
66 change=$(last_shelved_change) &&
67 git p4 unshelve $change &&
68 git show refs/remotes/p4-unshelved/$change | grep -q "Further description" &&
69 git cherry-pick refs/remotes/p4-unshelved/$change &&
70 test_path_is_file file2 &&
71 test_cmp file1 "$cli"/file1 &&
72 test_cmp file2 "$cli"/file2 &&
73 test_cmp file_to_integrate "$cli"/integrated_file &&
74 test_path_is_missing file_to_delete &&
75 test_path_is_missing file_to_move &&
76 test_path_is_file moved_file
80 test_expect_success
'update shelved changelist and re-unshelve' '
81 test_when_finished cleanup_git &&
84 change=$(last_shelved_change) &&
85 echo "file3" >file3 &&
86 p4 add -c $change file3 &&
87 p4 shelve -i -r <<EOF &&
97 //depot/file_to_delete
103 change=$(last_shelved_change) &&
104 git p4 unshelve $change &&
105 git diff refs/remotes/p4-unshelved/$change.0 refs/remotes/p4-unshelved/$change | grep -q file3
110 description
="Change to be unshelved" &&
121 # This is the tricky case where the shelved changelist base revision doesn't
122 # match git-p4's idea of the base revision
124 # We will attempt to unshelve a change that is based on a change one commit
127 test_expect_success
'create shelved changelist based on p4 change ahead of p4/master' '
128 git p4 clone --dest="$git" //depot/@all &&
133 echo "foo" >>file1 &&
134 p4 submit -d "change:foo" &&
136 echo "bar" >>file1 &&
137 shelve_one_file //depot/file1 &&
138 change=$(last_shelved_change) &&
139 p4 describe -S $change >out.txt &&
140 grep -q "Change to be unshelved" out.txt
144 # Now try to unshelve it.
145 test_expect_success
'try to unshelve the change' '
146 test_when_finished cleanup_git &&
148 change=$(last_shelved_change) &&
150 git p4 unshelve $change >out.txt &&
151 grep -q "unshelved changelist $change" out.txt
155 # Specify the origin. Create 2 unrelated files, and check that
156 # we only get the one in HEAD~, not the one in HEAD.
158 test_expect_success
'unshelve specifying the origin' '
161 : >unrelated_file0 &&
162 p4 add unrelated_file0 &&
163 p4 submit -d "unrelated" &&
164 : >unrelated_file1 &&
165 p4 add unrelated_file1 &&
166 p4 submit -d "unrelated" &&
168 p4 add file_to_shelve &&
169 shelve_one_file //depot/file_to_shelve
171 test_when_finished cleanup_git &&
172 git p4 clone --dest="$git" //depot/@all &&
175 change=$(last_shelved_change) &&
176 git p4 unshelve --origin HEAD~ $change &&
177 git checkout refs/remotes/p4-unshelved/$change &&
178 test_path_is_file unrelated_file0 &&
179 test_path_is_missing unrelated_file1 &&
180 test_path_is_file file_to_shelve