Merge branch 'rj/cygwin-has-dev-tty'
[git/gitster.git] / t / t9812-git-p4-wildcards.sh
blob46aa5fd56c7706ab23651112c40919cbdad2b354
1 #!/bin/sh
3 test_description='git p4 wildcards'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./lib-git-p4.sh
8 test_expect_success 'start p4d' '
9 start_p4d
12 test_expect_success 'add p4 files with wildcards in the names' '
14 cd "$cli" &&
15 printf "file2\nhas\nsome\nrandom\ntext\n" >file2 &&
16 p4 add file2 &&
17 echo file-wild-hash >file-wild#hash &&
18 if test_have_prereq !MINGW,!CYGWIN
19 then
20 echo file-wild-star >file-wild\*star
21 fi &&
22 echo file-wild-at >file-wild@at &&
23 echo file-wild-percent >file-wild%percent &&
24 p4 add -f file-wild* &&
25 p4 submit -d "file wildcards"
29 test_expect_success 'wildcard files git p4 clone' '
30 git p4 clone --dest="$git" //depot &&
31 test_when_finished cleanup_git &&
33 cd "$git" &&
34 test -f file-wild#hash &&
35 if test_have_prereq !MINGW,!CYGWIN
36 then
37 test -f file-wild\*star
38 fi &&
39 test -f file-wild@at &&
40 test -f file-wild%percent
44 test_expect_success 'wildcard files submit back to p4, add' '
45 test_when_finished cleanup_git &&
46 git p4 clone --dest="$git" //depot &&
48 cd "$git" &&
49 echo git-wild-hash >git-wild#hash &&
50 if test_have_prereq !MINGW,!CYGWIN
51 then
52 echo git-wild-star >git-wild\*star
53 fi &&
54 echo git-wild-at >git-wild@at &&
55 echo git-wild-percent >git-wild%percent &&
56 git add git-wild* &&
57 git commit -m "add some wildcard filenames" &&
58 git config git-p4.skipSubmitEdit true &&
59 git p4 submit
60 ) &&
62 cd "$cli" &&
63 test_path_is_file git-wild#hash &&
64 if test_have_prereq !MINGW,!CYGWIN
65 then
66 test_path_is_file git-wild\*star
67 fi &&
68 test_path_is_file git-wild@at &&
69 test_path_is_file git-wild%percent
73 test_expect_success 'wildcard files submit back to p4, modify' '
74 test_when_finished cleanup_git &&
75 git p4 clone --dest="$git" //depot &&
77 cd "$git" &&
78 echo new-line >>git-wild#hash &&
79 if test_have_prereq !MINGW,!CYGWIN
80 then
81 echo new-line >>git-wild\*star
82 fi &&
83 echo new-line >>git-wild@at &&
84 echo new-line >>git-wild%percent &&
85 git add git-wild* &&
86 git commit -m "modify the wildcard files" &&
87 git config git-p4.skipSubmitEdit true &&
88 git p4 submit
89 ) &&
91 cd "$cli" &&
92 test_line_count = 2 git-wild#hash &&
93 if test_have_prereq !MINGW,!CYGWIN
94 then
95 test_line_count = 2 git-wild\*star
96 fi &&
97 test_line_count = 2 git-wild@at &&
98 test_line_count = 2 git-wild%percent
102 test_expect_success 'wildcard files submit back to p4, copy' '
103 test_when_finished cleanup_git &&
104 git p4 clone --dest="$git" //depot &&
106 cd "$git" &&
107 cp file2 git-wild-cp#hash &&
108 git add git-wild-cp#hash &&
109 cp git-wild#hash file-wild-3 &&
110 git add file-wild-3 &&
111 git commit -m "wildcard copies" &&
112 git config git-p4.detectCopies true &&
113 git config git-p4.detectCopiesHarder true &&
114 git config git-p4.skipSubmitEdit true &&
115 git p4 submit
116 ) &&
118 cd "$cli" &&
119 test_path_is_file git-wild-cp#hash &&
120 test_path_is_file file-wild-3
124 test_expect_success 'wildcard files submit back to p4, rename' '
125 test_when_finished cleanup_git &&
126 git p4 clone --dest="$git" //depot &&
128 cd "$git" &&
129 git mv git-wild@at file-wild-4 &&
130 git mv file-wild-3 git-wild-cp%percent &&
131 git commit -m "wildcard renames" &&
132 git config git-p4.detectRenames true &&
133 git config git-p4.skipSubmitEdit true &&
134 git p4 submit
135 ) &&
137 cd "$cli" &&
138 test_path_is_missing git-wild@at &&
139 test_path_is_file git-wild-cp%percent
143 test_expect_success 'wildcard files submit back to p4, delete' '
144 test_when_finished cleanup_git &&
145 git p4 clone --dest="$git" //depot &&
147 cd "$git" &&
148 git rm git-wild* &&
149 git commit -m "delete the wildcard files" &&
150 git config git-p4.skipSubmitEdit true &&
151 git p4 submit
152 ) &&
154 cd "$cli" &&
155 test_path_is_missing git-wild#hash &&
156 if test_have_prereq !MINGW,!CYGWIN
157 then
158 test_path_is_missing git-wild\*star
159 fi &&
160 test_path_is_missing git-wild@at &&
161 test_path_is_missing git-wild%percent
165 test_expect_success 'p4 deleted a wildcard file' '
167 cd "$cli" &&
168 echo "wild delete test" >wild@delete &&
169 p4 add -f wild@delete &&
170 p4 submit -d "add wild@delete"
171 ) &&
172 test_when_finished cleanup_git &&
173 git p4 clone --dest="$git" //depot &&
175 cd "$git" &&
176 test_path_is_file wild@delete
177 ) &&
179 cd "$cli" &&
180 # must use its encoded name
181 p4 delete wild%40delete &&
182 p4 submit -d "delete wild@delete"
183 ) &&
185 cd "$git" &&
186 git p4 sync &&
187 git merge --ff-only p4/master &&
188 test_path_is_missing wild@delete
192 test_expect_success 'wildcard files requiring keyword scrub' '
194 cd "$cli" &&
195 cat <<-\EOF >scrub@wild &&
196 $Id$
197 line2
199 p4 add -t text+k -f scrub@wild &&
200 p4 submit -d "scrub at wild"
201 ) &&
202 test_when_finished cleanup_git &&
203 git p4 clone --dest="$git" //depot &&
205 cd "$git" &&
206 git config git-p4.skipSubmitEdit true &&
207 git config git-p4.attemptRCSCleanup true &&
208 sed "s/^line2/line2 edit/" <scrub@wild >scrub@wild.tmp &&
209 mv -f scrub@wild.tmp scrub@wild &&
210 git commit -m "scrub at wild line2 edit" scrub@wild &&
211 git p4 submit
215 test_done