]>
Commit | Line | Data |
---|---|---|
fc002330 PW |
1 | #!/bin/sh |
2 | ||
6ab1d76c | 3 | test_description='git p4 tests for p4 branches' |
fc002330 | 4 | |
46a29020 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
fc002330 PW |
8 | . ./lib-git-p4.sh |
9 | ||
10 | test_expect_success 'start p4d' ' | |
11 | start_p4d | |
12 | ' | |
13 | ||
14 | # | |
15 | # 1: //depot/main/f1 | |
16 | # 2: //depot/main/f2 | |
17 | # 3: integrate //depot/main/... -> //depot/branch1/... | |
18 | # 4: //depot/main/f4 | |
19 | # 5: //depot/branch1/f5 | |
20 | # .: named branch branch2 | |
21 | # 6: integrate -b branch2 | |
22 | # 7: //depot/branch2/f7 | |
23 | # 8: //depot/main/f8 | |
24 | # | |
25 | test_expect_success 'basic p4 branches' ' | |
26 | ( | |
27 | cd "$cli" && | |
28 | mkdir -p main && | |
29 | ||
30 | echo f1 >main/f1 && | |
31 | p4 add main/f1 && | |
32 | p4 submit -d "main/f1" && | |
33 | ||
34 | echo f2 >main/f2 && | |
35 | p4 add main/f2 && | |
36 | p4 submit -d "main/f2" && | |
37 | ||
38 | p4 integrate //depot/main/... //depot/branch1/... && | |
39 | p4 submit -d "integrate main to branch1" && | |
40 | ||
41 | echo f4 >main/f4 && | |
42 | p4 add main/f4 && | |
43 | p4 submit -d "main/f4" && | |
44 | ||
45 | echo f5 >branch1/f5 && | |
46 | p4 add branch1/f5 && | |
47 | p4 submit -d "branch1/f5" && | |
48 | ||
49 | p4 branch -i <<-EOF && | |
50 | Branch: branch2 | |
51 | View: //depot/main/... //depot/branch2/... | |
52 | EOF | |
53 | ||
54 | p4 integrate -b branch2 && | |
55 | p4 submit -d "integrate main to branch2" && | |
56 | ||
57 | echo f7 >branch2/f7 && | |
58 | p4 add branch2/f7 && | |
59 | p4 submit -d "branch2/f7" && | |
60 | ||
61 | echo f8 >main/f8 && | |
62 | p4 add main/f8 && | |
63 | p4 submit -d "main/f8" | |
64 | ) | |
65 | ' | |
66 | ||
67 | test_expect_success 'import main, no branch detection' ' | |
68 | test_when_finished cleanup_git && | |
6ab1d76c | 69 | git p4 clone --dest="$git" //depot/main@all && |
fc002330 PW |
70 | ( |
71 | cd "$git" && | |
72 | git log --oneline --graph --decorate --all && | |
46a29020 | 73 | git rev-list main -- >wc && |
fc002330 PW |
74 | test_line_count = 4 wc |
75 | ) | |
76 | ' | |
77 | ||
78 | test_expect_success 'import branch1, no branch detection' ' | |
79 | test_when_finished cleanup_git && | |
6ab1d76c | 80 | git p4 clone --dest="$git" //depot/branch1@all && |
fc002330 PW |
81 | ( |
82 | cd "$git" && | |
83 | git log --oneline --graph --decorate --all && | |
46a29020 | 84 | git rev-list main -- >wc && |
fc002330 PW |
85 | test_line_count = 2 wc |
86 | ) | |
87 | ' | |
88 | ||
89 | test_expect_success 'import branch2, no branch detection' ' | |
90 | test_when_finished cleanup_git && | |
6ab1d76c | 91 | git p4 clone --dest="$git" //depot/branch2@all && |
fc002330 PW |
92 | ( |
93 | cd "$git" && | |
94 | git log --oneline --graph --decorate --all && | |
46a29020 | 95 | git rev-list main -- >wc && |
fc002330 PW |
96 | test_line_count = 2 wc |
97 | ) | |
98 | ' | |
99 | ||
100 | test_expect_success 'import depot, no branch detection' ' | |
101 | test_when_finished cleanup_git && | |
6ab1d76c | 102 | git p4 clone --dest="$git" //depot@all && |
fc002330 PW |
103 | ( |
104 | cd "$git" && | |
105 | git log --oneline --graph --decorate --all && | |
46a29020 | 106 | git rev-list main -- >wc && |
fc002330 PW |
107 | test_line_count = 8 wc |
108 | ) | |
109 | ' | |
110 | ||
111 | test_expect_success 'import depot, branch detection' ' | |
112 | test_when_finished cleanup_git && | |
6ab1d76c | 113 | git p4 clone --dest="$git" --detect-branches //depot@all && |
fc002330 PW |
114 | ( |
115 | cd "$git" && | |
116 | ||
117 | git log --oneline --graph --decorate --all && | |
118 | ||
119 | # 4 main commits | |
46a29020 | 120 | git rev-list main -- >wc && |
fc002330 PW |
121 | test_line_count = 4 wc && |
122 | ||
123 | # 3 main, 1 integrate, 1 on branch2 | |
124 | git rev-list p4/depot/branch2 >wc && | |
125 | test_line_count = 5 wc && | |
126 | ||
127 | # no branch1, since no p4 branch created for it | |
128 | test_must_fail git show-ref p4/depot/branch1 | |
129 | ) | |
130 | ' | |
131 | ||
17f273ff TK |
132 | test_expect_success 'sync specific detected branch' ' |
133 | test_when_finished cleanup_git && | |
134 | git p4 clone --dest="$git" --detect-branches //depot@all && | |
135 | ( | |
136 | cd "$git" && | |
137 | git p4 sync --branch=depot/branch2 >out && | |
138 | test_i18ngrep "No changes to import!" out | |
139 | ) | |
140 | ' | |
141 | ||
fc002330 PW |
142 | test_expect_success 'import depot, branch detection, branchList branch definition' ' |
143 | test_when_finished cleanup_git && | |
144 | test_create_repo "$git" && | |
145 | ( | |
146 | cd "$git" && | |
147 | git config git-p4.branchList main:branch1 && | |
6ab1d76c | 148 | git p4 clone --dest=. --detect-branches //depot@all && |
fc002330 PW |
149 | |
150 | git log --oneline --graph --decorate --all && | |
151 | ||
152 | # 4 main commits | |
46a29020 | 153 | git rev-list main -- >wc && |
fc002330 PW |
154 | test_line_count = 4 wc && |
155 | ||
156 | # 3 main, 1 integrate, 1 on branch2 | |
157 | git rev-list p4/depot/branch2 >wc && | |
158 | test_line_count = 5 wc && | |
159 | ||
160 | # 2 main, 1 integrate, 1 on branch1 | |
161 | git rev-list p4/depot/branch1 >wc && | |
162 | test_line_count = 4 wc | |
163 | ) | |
164 | ' | |
165 | ||
166 | test_expect_success 'restart p4d' ' | |
07353d90 | 167 | stop_and_cleanup_p4d && |
fc002330 PW |
168 | start_p4d |
169 | ' | |
170 | ||
171 | # | |
172 | # 1: //depot/branch1/file1 | |
173 | # //depot/branch1/file2 | |
174 | # 2: integrate //depot/branch1/... -> //depot/branch2/... | |
175 | # 3: //depot/branch1/file3 | |
176 | # 4: //depot/branch1/file2 (edit) | |
177 | # 5: integrate //depot/branch1/... -> //depot/branch3/... | |
178 | # | |
179 | ## Create a simple branch structure in P4 depot. | |
180 | test_expect_success 'add simple p4 branches' ' | |
181 | ( | |
182 | cd "$cli" && | |
183 | mkdir branch1 && | |
184 | cd branch1 && | |
185 | echo file1 >file1 && | |
186 | echo file2 >file2 && | |
187 | p4 add file1 file2 && | |
c5665efe | 188 | p4 submit -d "Create branch1" && |
fc002330 | 189 | p4 integrate //depot/branch1/... //depot/branch2/... && |
c5665efe | 190 | p4 submit -d "Integrate branch2 from branch1" && |
fc002330 PW |
191 | echo file3 >file3 && |
192 | p4 add file3 && | |
193 | p4 submit -d "add file3 in branch1" && | |
194 | p4 open file2 && | |
195 | echo update >>file2 && | |
196 | p4 submit -d "update file2 in branch1" && | |
197 | p4 integrate //depot/branch1/... //depot/branch3/... && | |
c5665efe | 198 | p4 submit -d "Integrate branch3 from branch1" |
fc002330 PW |
199 | ) |
200 | ' | |
201 | ||
202 | # Configure branches through git-config and clone them. | |
203 | # All files are tested to make sure branches were cloned correctly. | |
204 | # Finally, make an update to branch1 on P4 side to check if it is imported | |
6ab1d76c PW |
205 | # correctly by git p4. |
206 | test_expect_success 'git p4 clone simple branches' ' | |
fc002330 PW |
207 | test_when_finished cleanup_git && |
208 | test_create_repo "$git" && | |
209 | ( | |
210 | cd "$git" && | |
211 | git config git-p4.branchList branch1:branch2 && | |
212 | git config --add git-p4.branchList branch1:branch3 && | |
6ab1d76c | 213 | git p4 clone --dest=. --detect-branches //depot@all && |
fc002330 PW |
214 | git log --all --graph --decorate --stat && |
215 | git reset --hard p4/depot/branch1 && | |
12604a8d SV |
216 | test_path_is_file file1 && |
217 | test_path_is_file file2 && | |
218 | test_path_is_file file3 && | |
c5665efe | 219 | grep update file2 && |
fc002330 | 220 | git reset --hard p4/depot/branch2 && |
12604a8d SV |
221 | test_path_is_file file1 && |
222 | test_path_is_file file2 && | |
fc002330 | 223 | test ! -f file3 && |
e7d7a567 | 224 | ! grep update file2 && |
fc002330 | 225 | git reset --hard p4/depot/branch3 && |
12604a8d SV |
226 | test_path_is_file file1 && |
227 | test_path_is_file file2 && | |
228 | test_path_is_file file3 && | |
c5665efe | 229 | grep update file2 && |
fc002330 PW |
230 | cd "$cli" && |
231 | cd branch1 && | |
232 | p4 edit file2 && | |
233 | echo file2_ >>file2 && | |
5d5c556a | 234 | p4 submit -d "update file2 in branch1" && |
fc002330 PW |
235 | cd "$git" && |
236 | git reset --hard p4/depot/branch1 && | |
6ab1d76c | 237 | git p4 rebase && |
c5665efe VA |
238 | grep file2_ file2 |
239 | ) | |
240 | ' | |
241 | ||
242 | # Create a complex branch structure in P4 depot to check if they are correctly | |
6ab1d76c | 243 | # cloned. The branches are created from older changelists to check if git p4 is |
c5665efe VA |
244 | # able to correctly detect them. |
245 | # The final expected structure is: | |
246 | # `branch1 | |
247 | # | `- file1 | |
248 | # | `- file2 (updated) | |
249 | # | `- file3 | |
250 | # `branch2 | |
251 | # | `- file1 | |
252 | # | `- file2 | |
253 | # `branch3 | |
254 | # | `- file1 | |
255 | # | `- file2 (updated) | |
256 | # | `- file3 | |
257 | # `branch4 | |
258 | # | `- file1 | |
259 | # | `- file2 | |
260 | # `branch5 | |
261 | # `- file1 | |
262 | # `- file2 | |
263 | # `- file3 | |
6ab1d76c | 264 | test_expect_success 'git p4 add complex branches' ' |
c5665efe VA |
265 | ( |
266 | cd "$cli" && | |
267 | changelist=$(p4 changes -m1 //depot/... | cut -d" " -f2) && | |
268 | changelist=$(($changelist - 5)) && | |
269 | p4 integrate //depot/branch1/...@$changelist //depot/branch4/... && | |
270 | p4 submit -d "Integrate branch4 from branch1@${changelist}" && | |
271 | changelist=$(($changelist + 2)) && | |
272 | p4 integrate //depot/branch1/...@$changelist //depot/branch5/... && | |
273 | p4 submit -d "Integrate branch5 from branch1@${changelist}" | |
274 | ) | |
275 | ' | |
276 | ||
6ab1d76c | 277 | # Configure branches through git-config and clone them. git p4 will only be able |
c5665efe VA |
278 | # to clone the original structure if it is able to detect the origin changelist |
279 | # of each branch. | |
6ab1d76c | 280 | test_expect_success 'git p4 clone complex branches' ' |
c5665efe VA |
281 | test_when_finished cleanup_git && |
282 | test_create_repo "$git" && | |
283 | ( | |
284 | cd "$git" && | |
285 | git config git-p4.branchList branch1:branch2 && | |
286 | git config --add git-p4.branchList branch1:branch3 && | |
287 | git config --add git-p4.branchList branch1:branch4 && | |
288 | git config --add git-p4.branchList branch1:branch5 && | |
6ab1d76c | 289 | git p4 clone --dest=. --detect-branches //depot@all && |
c5665efe VA |
290 | git log --all --graph --decorate --stat && |
291 | git reset --hard p4/depot/branch1 && | |
292 | test_path_is_file file1 && | |
293 | test_path_is_file file2 && | |
294 | test_path_is_file file3 && | |
295 | grep update file2 && | |
296 | git reset --hard p4/depot/branch2 && | |
297 | test_path_is_file file1 && | |
298 | test_path_is_file file2 && | |
299 | test_path_is_missing file3 && | |
e7d7a567 | 300 | ! grep update file2 && |
c5665efe VA |
301 | git reset --hard p4/depot/branch3 && |
302 | test_path_is_file file1 && | |
303 | test_path_is_file file2 && | |
304 | test_path_is_file file3 && | |
305 | grep update file2 && | |
306 | git reset --hard p4/depot/branch4 && | |
c3ab0884 | 307 | git diff-tree --quiet HEAD && |
c5665efe VA |
308 | test_path_is_file file1 && |
309 | test_path_is_file file2 && | |
310 | test_path_is_missing file3 && | |
e7d7a567 | 311 | ! grep update file2 && |
c5665efe | 312 | git reset --hard p4/depot/branch5 && |
c3ab0884 | 313 | git diff-tree --quiet HEAD && |
c5665efe VA |
314 | test_path_is_file file1 && |
315 | test_path_is_file file2 && | |
316 | test_path_is_file file3 && | |
e7d7a567 | 317 | ! grep update file2 && |
d604176d | 318 | test_must_fail git show-ref --verify refs/git-p4-tmp |
fc002330 PW |
319 | ) |
320 | ' | |
321 | ||
9e826dfd VA |
322 | # Move branch3/file3 to branch4/file3 in a single changelist |
323 | test_expect_success 'git p4 submit to two branches in a single changelist' ' | |
324 | ( | |
325 | cd "$cli" && | |
326 | p4 integrate //depot/branch3/file3 //depot/branch4/file3 && | |
327 | p4 delete //depot/branch3/file3 && | |
328 | p4 submit -d "Move branch3/file3 to branch4/file3" | |
329 | ) | |
330 | ' | |
331 | ||
332 | # Confirm that changes to two branches done in a single changelist | |
333 | # are correctly imported by git p4 | |
334 | test_expect_success 'git p4 sync changes to two branches in the same changelist' ' | |
335 | test_when_finished cleanup_git && | |
336 | test_create_repo "$git" && | |
337 | ( | |
338 | cd "$git" && | |
339 | git config git-p4.branchList branch1:branch2 && | |
340 | git config --add git-p4.branchList branch1:branch3 && | |
341 | git config --add git-p4.branchList branch1:branch4 && | |
342 | git config --add git-p4.branchList branch1:branch5 && | |
343 | git p4 clone --dest=. --detect-branches //depot@all && | |
344 | git log --all --graph --decorate --stat && | |
345 | git reset --hard p4/depot/branch1 && | |
346 | test_path_is_file file1 && | |
347 | test_path_is_file file2 && | |
348 | test_path_is_file file3 && | |
349 | grep update file2 && | |
350 | git reset --hard p4/depot/branch2 && | |
351 | test_path_is_file file1 && | |
352 | test_path_is_file file2 && | |
353 | test_path_is_missing file3 && | |
354 | ! grep update file2 && | |
355 | git reset --hard p4/depot/branch3 && | |
356 | test_path_is_file file1 && | |
357 | test_path_is_file file2 && | |
358 | test_path_is_missing file3 && | |
359 | grep update file2 && | |
360 | git reset --hard p4/depot/branch4 && | |
361 | test_path_is_file file1 && | |
362 | test_path_is_file file2 && | |
363 | test_path_is_file file3 && | |
364 | ! grep update file2 && | |
365 | git reset --hard p4/depot/branch5 && | |
366 | test_path_is_file file1 && | |
367 | test_path_is_file file2 && | |
368 | test_path_is_file file3 && | |
369 | ! grep update file2 && | |
d604176d | 370 | test_must_fail git show-ref --verify refs/git-p4-tmp |
9e826dfd VA |
371 | ) |
372 | ' | |
373 | ||
ad71f661 VA |
374 | # Create a branch by integrating a single file |
375 | test_expect_success 'git p4 file subset branch' ' | |
376 | ( | |
377 | cd "$cli" && | |
378 | p4 integrate //depot/branch1/file1 //depot/branch6/file1 && | |
379 | p4 submit -d "Integrate file1 alone from branch1 to branch6" | |
380 | ) | |
381 | ' | |
382 | ||
383 | # Check if git p4 creates a new branch containing a single file, | |
384 | # instead of keeping the old files from the original branch | |
385 | test_expect_failure 'git p4 clone file subset branch' ' | |
386 | test_when_finished cleanup_git && | |
387 | test_create_repo "$git" && | |
388 | ( | |
389 | cd "$git" && | |
390 | git config git-p4.branchList branch1:branch2 && | |
391 | git config --add git-p4.branchList branch1:branch3 && | |
392 | git config --add git-p4.branchList branch1:branch4 && | |
393 | git config --add git-p4.branchList branch1:branch5 && | |
394 | git config --add git-p4.branchList branch1:branch6 && | |
395 | git p4 clone --dest=. --detect-branches //depot@all && | |
396 | git log --all --graph --decorate --stat && | |
397 | git reset --hard p4/depot/branch1 && | |
398 | test_path_is_file file1 && | |
399 | test_path_is_file file2 && | |
400 | test_path_is_file file3 && | |
401 | grep update file2 && | |
402 | git reset --hard p4/depot/branch2 && | |
403 | test_path_is_file file1 && | |
404 | test_path_is_file file2 && | |
405 | test_path_is_missing file3 && | |
406 | ! grep update file2 && | |
407 | git reset --hard p4/depot/branch3 && | |
408 | test_path_is_file file1 && | |
409 | test_path_is_file file2 && | |
410 | test_path_is_missing file3 && | |
411 | grep update file2 && | |
412 | git reset --hard p4/depot/branch4 && | |
413 | test_path_is_file file1 && | |
414 | test_path_is_file file2 && | |
415 | test_path_is_file file3 && | |
416 | ! grep update file2 && | |
417 | git reset --hard p4/depot/branch5 && | |
418 | test_path_is_file file1 && | |
419 | test_path_is_file file2 && | |
420 | test_path_is_file file3 && | |
421 | ! grep update file2 && | |
422 | git reset --hard p4/depot/branch6 && | |
423 | test_path_is_file file1 && | |
424 | test_path_is_missing file2 && | |
425 | test_path_is_missing file3 | |
426 | ) | |
427 | ' | |
19516356 | 428 | |
607a3be6 | 429 | # Check that excluded files are omitted during import |
d15068a6 | 430 | test_expect_success 'git p4 clone complex branches with excluded files' ' |
607a3be6 AM |
431 | test_when_finished cleanup_git && |
432 | test_create_repo "$git" && | |
433 | ( | |
434 | cd "$git" && | |
435 | git config git-p4.branchList branch1:branch2 && | |
436 | git config --add git-p4.branchList branch1:branch3 && | |
437 | git config --add git-p4.branchList branch1:branch4 && | |
438 | git config --add git-p4.branchList branch1:branch5 && | |
439 | git config --add git-p4.branchList branch1:branch6 && | |
440 | git p4 clone --dest=. --detect-branches -//depot/branch1/file2 -//depot/branch2/file2 -//depot/branch3/file2 -//depot/branch4/file2 -//depot/branch5/file2 -//depot/branch6/file2 //depot@all && | |
441 | git log --all --graph --decorate --stat && | |
442 | git reset --hard p4/depot/branch1 && | |
443 | test_path_is_file file1 && | |
444 | test_path_is_missing file2 && | |
445 | test_path_is_file file3 && | |
446 | git reset --hard p4/depot/branch2 && | |
447 | test_path_is_file file1 && | |
448 | test_path_is_missing file2 && | |
449 | test_path_is_missing file3 && | |
450 | git reset --hard p4/depot/branch3 && | |
451 | test_path_is_file file1 && | |
452 | test_path_is_missing file2 && | |
453 | test_path_is_missing file3 && | |
454 | git reset --hard p4/depot/branch4 && | |
455 | test_path_is_file file1 && | |
456 | test_path_is_missing file2 && | |
457 | test_path_is_file file3 && | |
458 | git reset --hard p4/depot/branch5 && | |
459 | test_path_is_file file1 && | |
460 | test_path_is_missing file2 && | |
461 | test_path_is_file file3 && | |
462 | git reset --hard p4/depot/branch6 && | |
463 | test_path_is_file file1 && | |
464 | test_path_is_missing file2 && | |
465 | test_path_is_missing file3 | |
466 | ) | |
467 | ' | |
468 | ||
19516356 PW |
469 | # From a report in http://stackoverflow.com/questions/11893688 |
470 | # where --use-client-spec caused branch prefixes not to be removed; | |
471 | # every file in git appeared into a subdirectory of the branch name. | |
472 | test_expect_success 'use-client-spec detect-branches setup' ' | |
473 | rm -rf "$cli" && | |
474 | mkdir "$cli" && | |
475 | ( | |
476 | cd "$cli" && | |
477 | client_view "//depot/usecs/... //client/..." && | |
478 | mkdir b1 && | |
479 | echo b1/b1-file1 >b1/b1-file1 && | |
480 | p4 add b1/b1-file1 && | |
481 | p4 submit -d "b1/b1-file1" && | |
482 | ||
483 | p4 integrate //depot/usecs/b1/... //depot/usecs/b2/... && | |
484 | p4 submit -d "b1 -> b2" && | |
485 | p4 branch -i <<-EOF && | |
486 | Branch: b2 | |
487 | View: //depot/usecs/b1/... //depot/usecs/b2/... | |
488 | EOF | |
489 | ||
490 | echo b2/b2-file2 >b2/b2-file2 && | |
491 | p4 add b2/b2-file2 && | |
492 | p4 submit -d "b2/b2-file2" | |
493 | ) | |
494 | ' | |
495 | ||
21ef5df4 | 496 | test_expect_success 'use-client-spec detect-branches files in top-level' ' |
19516356 PW |
497 | test_when_finished cleanup_git && |
498 | test_create_repo "$git" && | |
499 | ( | |
500 | cd "$git" && | |
501 | git p4 sync --detect-branches --use-client-spec //depot/usecs@all && | |
46a29020 | 502 | git checkout -b main p4/usecs/b1 && |
19516356 PW |
503 | test_path_is_file b1-file1 && |
504 | test_path_is_missing b2-file2 && | |
505 | test_path_is_missing b1 && | |
506 | test_path_is_missing b2 && | |
507 | ||
508 | git checkout -b b2 p4/usecs/b2 && | |
509 | test_path_is_file b1-file1 && | |
510 | test_path_is_file b2-file2 && | |
511 | test_path_is_missing b1 && | |
512 | test_path_is_missing b2 | |
513 | ) | |
514 | ' | |
515 | ||
516 | test_expect_success 'use-client-spec detect-branches skips branches setup' ' | |
517 | ( | |
518 | cd "$cli" && | |
519 | ||
520 | p4 integrate //depot/usecs/b1/... //depot/usecs/b3/... && | |
521 | p4 submit -d "b1 -> b3" && | |
522 | p4 branch -i <<-EOF && | |
523 | Branch: b3 | |
524 | View: //depot/usecs/b1/... //depot/usecs/b3/... | |
525 | EOF | |
526 | ||
7c8ce4ed VA |
527 | echo b3/b3-file3_1 >b3/b3-file3_1 && |
528 | echo b3/b3-file3_2 >b3/b3-file3_2 && | |
529 | p4 add b3/b3-file3_1 && | |
530 | p4 add b3/b3-file3_2 && | |
531 | p4 submit -d "b3/b3-file3_1 b3/b3-file3_2" | |
19516356 PW |
532 | ) |
533 | ' | |
534 | ||
535 | test_expect_success 'use-client-spec detect-branches skips branches' ' | |
536 | client_view "//depot/usecs/... //client/..." \ | |
537 | "-//depot/usecs/b3/... //client/b3/..." && | |
538 | test_when_finished cleanup_git && | |
539 | test_create_repo "$git" && | |
540 | ( | |
541 | cd "$git" && | |
542 | git p4 sync --detect-branches --use-client-spec //depot/usecs@all && | |
543 | test_must_fail git rev-parse refs/remotes/p4/usecs/b3 | |
544 | ) | |
545 | ' | |
546 | ||
7c8ce4ed VA |
547 | test_expect_success 'use-client-spec detect-branches skips files in branches' ' |
548 | client_view "//depot/usecs/... //client/..." \ | |
549 | "-//depot/usecs/b3/b3-file3_1 //client/b3/b3-file3_1" && | |
550 | test_when_finished cleanup_git && | |
551 | test_create_repo "$git" && | |
552 | ( | |
553 | cd "$git" && | |
554 | git p4 sync --detect-branches --use-client-spec //depot/usecs@all && | |
46a29020 | 555 | git checkout -b main p4/usecs/b3 && |
7c8ce4ed VA |
556 | test_path_is_file b1-file1 && |
557 | test_path_is_file b3-file3_2 && | |
558 | test_path_is_missing b3-file3_1 | |
559 | ) | |
560 | ' | |
561 | ||
591707a7 | 562 | test_expect_success 'restart p4d' ' |
07353d90 | 563 | stop_and_cleanup_p4d && |
591707a7 VA |
564 | start_p4d |
565 | ' | |
566 | ||
567 | # | |
568 | # 1: //depot/branch1/base/file1 | |
569 | # //depot/branch1/base/file2 | |
570 | # //depot/branch1/base/dir/sub_file1 | |
571 | # 2: integrate //depot/branch1/base/... -> //depot/branch2/base/... | |
572 | # 3: //depot/branch1/base/file3 | |
573 | # 4: //depot/branch1/base/file2 (edit) | |
574 | # 5: integrate //depot/branch1/base/... -> //depot/branch3/base/... | |
575 | # | |
576 | # Note: the client view removes the "base" folder from the workspace | |
577 | # and moves sub_file1 one level up. | |
578 | test_expect_success 'add simple p4 branches with common base folder on each branch' ' | |
579 | ( | |
580 | cd "$cli" && | |
581 | client_view "//depot/branch1/base/... //client/branch1/..." \ | |
582 | "//depot/branch1/base/dir/sub_file1 //client/branch1/sub_file1" \ | |
583 | "//depot/branch2/base/... //client/branch2/..." \ | |
584 | "//depot/branch3/base/... //client/branch3/..." && | |
585 | mkdir -p branch1 && | |
586 | cd branch1 && | |
587 | echo file1 >file1 && | |
588 | echo file2 >file2 && | |
589 | mkdir dir && | |
590 | echo sub_file1 >sub_file1 && | |
591 | p4 add file1 file2 sub_file1 && | |
592 | p4 submit -d "Create branch1" && | |
593 | p4 integrate //depot/branch1/base/... //depot/branch2/base/... && | |
594 | p4 submit -d "Integrate branch2 from branch1" && | |
595 | echo file3 >file3 && | |
596 | p4 add file3 && | |
597 | p4 submit -d "add file3 in branch1" && | |
598 | p4 open file2 && | |
599 | echo update >>file2 && | |
600 | p4 submit -d "update file2 in branch1" && | |
601 | p4 integrate //depot/branch1/base/... //depot/branch3/base/... && | |
602 | p4 submit -d "Integrate branch3 from branch1" | |
603 | ) | |
604 | ' | |
605 | ||
606 | # Configure branches through git-config and clone them. | |
607 | # All files are tested to make sure branches were cloned correctly. | |
608 | # Finally, make an update to branch1 on P4 side to check if it is imported | |
609 | # correctly by git p4. | |
610 | # git p4 is expected to use the client view to also not include the common | |
611 | # "base" folder in the imported directory structure. | |
612 | test_expect_success 'git p4 clone simple branches with base folder on server side' ' | |
613 | test_create_repo "$git" && | |
614 | ( | |
615 | cd "$git" && | |
616 | git config git-p4.branchList branch1:branch2 && | |
617 | git config --add git-p4.branchList branch1:branch3 && | |
618 | git p4 clone --dest=. --use-client-spec --detect-branches //depot@all && | |
619 | git log --all --graph --decorate --stat && | |
620 | git reset --hard p4/depot/branch1 && | |
12604a8d SV |
621 | test_path_is_file file1 && |
622 | test_path_is_file file2 && | |
623 | test_path_is_file file3 && | |
624 | test_path_is_file sub_file1 && | |
591707a7 VA |
625 | grep update file2 && |
626 | git reset --hard p4/depot/branch2 && | |
12604a8d SV |
627 | test_path_is_file file1 && |
628 | test_path_is_file file2 && | |
591707a7 | 629 | test ! -f file3 && |
12604a8d | 630 | test_path_is_file sub_file1 && |
591707a7 VA |
631 | ! grep update file2 && |
632 | git reset --hard p4/depot/branch3 && | |
12604a8d SV |
633 | test_path_is_file file1 && |
634 | test_path_is_file file2 && | |
635 | test_path_is_file file3 && | |
636 | test_path_is_file sub_file1 && | |
591707a7 VA |
637 | grep update file2 && |
638 | cd "$cli" && | |
639 | cd branch1 && | |
640 | p4 edit file2 && | |
641 | echo file2_ >>file2 && | |
642 | p4 submit -d "update file2 in branch1" && | |
643 | cd "$git" && | |
644 | git reset --hard p4/depot/branch1 && | |
645 | git p4 rebase && | |
646 | grep file2_ file2 | |
647 | ) | |
648 | ' | |
649 | ||
650 | # Now update a file in one of the branches in git and submit to P4 | |
cd884106 | 651 | test_expect_success 'Update a file in git side and submit to P4 using client view' ' |
591707a7 VA |
652 | test_when_finished cleanup_git && |
653 | ( | |
654 | cd "$git" && | |
655 | git reset --hard p4/depot/branch1 && | |
656 | echo "client spec" >> file1 && | |
657 | git add -u . && | |
658 | git commit -m "update file1 in branch1" && | |
659 | git config git-p4.skipSubmitEdit true && | |
660 | git p4 submit --verbose && | |
661 | cd "$cli" && | |
662 | p4 sync ... && | |
663 | cd branch1 && | |
664 | grep "client spec" file1 | |
665 | ) | |
666 | ' | |
667 | ||
b30efb15 | 668 | test_expect_success 'restart p4d (case folding enabled)' ' |
44275f5e | 669 | stop_and_cleanup_p4d && |
b30efb15 AM |
670 | start_p4d -C1 |
671 | ' | |
672 | ||
673 | # | |
674 | # 1: //depot/main/mf1 | |
675 | # 2: integrate //depot/main/... -> //depot/branch1/... | |
676 | # 3: //depot/main/mf2 | |
677 | # 4: //depot/BRANCH1/B1f3 | |
678 | # 5: //depot/branch1/b1f4 | |
679 | # | |
680 | test_expect_success !CASE_INSENSITIVE_FS 'basic p4 branches for case folding' ' | |
681 | ( | |
682 | cd "$cli" && | |
683 | mkdir -p main && | |
684 | ||
685 | echo mf1 >main/mf1 && | |
686 | p4 add main/mf1 && | |
687 | p4 submit -d "main/mf1" && | |
688 | ||
689 | p4 integrate //depot/main/... //depot/branch1/... && | |
690 | p4 submit -d "integrate main to branch1" && | |
691 | ||
692 | echo mf2 >main/mf2 && | |
693 | p4 add main/mf2 && | |
694 | p4 submit -d "main/mf2" && | |
695 | ||
696 | mkdir BRANCH1 && | |
697 | echo B1f3 >BRANCH1/B1f3 && | |
698 | p4 add BRANCH1/B1f3 && | |
699 | p4 submit -d "BRANCH1/B1f3" && | |
700 | ||
701 | echo b1f4 >branch1/b1f4 && | |
702 | p4 add branch1/b1f4 && | |
703 | p4 submit -d "branch1/b1f4" | |
704 | ) | |
705 | ' | |
706 | ||
707 | # Check that files are properly split across branches when ignorecase is set | |
f2768cb3 | 708 | test_expect_success !CASE_INSENSITIVE_FS 'git p4 clone, branchList branch definition, ignorecase' ' |
b30efb15 AM |
709 | test_when_finished cleanup_git && |
710 | test_create_repo "$git" && | |
711 | ( | |
712 | cd "$git" && | |
713 | git config git-p4.branchList main:branch1 && | |
714 | git config --type=bool core.ignoreCase true && | |
715 | git p4 clone --dest=. --detect-branches //depot@all && | |
716 | ||
717 | git log --all --graph --decorate --stat && | |
718 | ||
719 | git reset --hard p4/master && | |
720 | test_path_is_file mf1 && | |
721 | test_path_is_file mf2 && | |
722 | test_path_is_missing B1f3 && | |
723 | test_path_is_missing b1f4 && | |
724 | ||
725 | git reset --hard p4/depot/branch1 && | |
726 | test_path_is_file mf1 && | |
727 | test_path_is_missing mf2 && | |
728 | test_path_is_file B1f3 && | |
729 | test_path_is_file b1f4 | |
730 | ) | |
731 | ' | |
732 | ||
733 | # Check that files are properly split across branches when ignorecase is set, use-client-spec case | |
f2768cb3 | 734 | test_expect_success !CASE_INSENSITIVE_FS 'git p4 clone with client-spec, branchList branch definition, ignorecase' ' |
b30efb15 AM |
735 | client_view "//depot/... //client/..." && |
736 | test_when_finished cleanup_git && | |
737 | test_create_repo "$git" && | |
738 | ( | |
739 | cd "$git" && | |
740 | git config git-p4.branchList main:branch1 && | |
741 | git config --type=bool core.ignoreCase true && | |
742 | git p4 clone --dest=. --use-client-spec --detect-branches //depot@all && | |
743 | ||
744 | git log --all --graph --decorate --stat && | |
745 | ||
746 | git reset --hard p4/master && | |
747 | test_path_is_file mf1 && | |
748 | test_path_is_file mf2 && | |
749 | test_path_is_missing B1f3 && | |
750 | test_path_is_missing b1f4 && | |
751 | ||
752 | git reset --hard p4/depot/branch1 && | |
753 | test_path_is_file mf1 && | |
754 | test_path_is_missing mf2 && | |
755 | test_path_is_file B1f3 && | |
756 | test_path_is_file b1f4 | |
757 | ) | |
758 | ' | |
759 | ||
fc002330 | 760 | test_done |