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