Merge branch 'jc/calloc-fix'
[git] / t / t9801-git-p4-branch.sh
1 #!/bin/sh
2
3 test_description='git p4 tests for p4 branches'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
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 &&
69         git p4 clone --dest="$git" //depot/main@all &&
70         (
71                 cd "$git" &&
72                 git log --oneline --graph --decorate --all &&
73                 git rev-list main -- >wc &&
74                 test_line_count = 4 wc
75         )
76 '
77
78 test_expect_success 'import branch1, no branch detection' '
79         test_when_finished cleanup_git &&
80         git p4 clone --dest="$git" //depot/branch1@all &&
81         (
82                 cd "$git" &&
83                 git log --oneline --graph --decorate --all &&
84                 git rev-list main -- >wc &&
85                 test_line_count = 2 wc
86         )
87 '
88
89 test_expect_success 'import branch2, no branch detection' '
90         test_when_finished cleanup_git &&
91         git p4 clone --dest="$git" //depot/branch2@all &&
92         (
93                 cd "$git" &&
94                 git log --oneline --graph --decorate --all &&
95                 git rev-list main -- >wc &&
96                 test_line_count = 2 wc
97         )
98 '
99
100 test_expect_success 'import depot, no branch detection' '
101         test_when_finished cleanup_git &&
102         git p4 clone --dest="$git" //depot@all &&
103         (
104                 cd "$git" &&
105                 git log --oneline --graph --decorate --all &&
106                 git rev-list main -- >wc &&
107                 test_line_count = 8 wc
108         )
109 '
110
111 test_expect_success 'import depot, branch detection' '
112         test_when_finished cleanup_git &&
113         git p4 clone --dest="$git" --detect-branches //depot@all &&
114         (
115                 cd "$git" &&
116
117                 git log --oneline --graph --decorate --all &&
118
119                 # 4 main commits
120                 git rev-list main -- >wc &&
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 &&
138                 git p4 clone --dest=. --detect-branches //depot@all &&
139
140                 git log --oneline --graph --decorate --all &&
141
142                 # 4 main commits
143                 git rev-list main -- >wc &&
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' '
157         stop_and_cleanup_p4d &&
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 &&
178                 p4 submit -d "Create branch1" &&
179                 p4 integrate //depot/branch1/... //depot/branch2/... &&
180                 p4 submit -d "Integrate branch2 from branch1" &&
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/... &&
188                 p4 submit -d "Integrate branch3 from branch1"
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
195 # correctly by git p4.
196 test_expect_success 'git p4 clone simple branches' '
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 &&
203                 git p4 clone --dest=. --detect-branches //depot@all &&
204                 git log --all --graph --decorate --stat &&
205                 git reset --hard p4/depot/branch1 &&
206                 test -f file1 &&
207                 test -f file2 &&
208                 test -f file3 &&
209                 grep update file2 &&
210                 git reset --hard p4/depot/branch2 &&
211                 test -f file1 &&
212                 test -f file2 &&
213                 test ! -f file3 &&
214                 ! grep update file2 &&
215                 git reset --hard p4/depot/branch3 &&
216                 test -f file1 &&
217                 test -f file2 &&
218                 test -f file3 &&
219                 grep update file2 &&
220                 cd "$cli" &&
221                 cd branch1 &&
222                 p4 edit file2 &&
223                 echo file2_ >>file2 &&
224                 p4 submit -d "update file2 in branch1" &&
225                 cd "$git" &&
226                 git reset --hard p4/depot/branch1 &&
227                 git p4 rebase &&
228                 grep file2_ file2
229         )
230 '
231
232 # Create a complex branch structure in P4 depot to check if they are correctly
233 # cloned. The branches are created from older changelists to check if git p4 is
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
254 test_expect_success 'git p4 add complex branches' '
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
267 # Configure branches through git-config and clone them. git p4 will only be able
268 # to clone the original structure if it is able to detect the origin changelist
269 # of each branch.
270 test_expect_success 'git p4 clone complex branches' '
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 &&
279                 git p4 clone --dest=. --detect-branches //depot@all &&
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 &&
290                 ! grep update file2 &&
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 &&
297                 test_path_is_file file1 &&
298                 test_path_is_file file2 &&
299                 test_path_is_missing file3 &&
300                 ! grep update file2 &&
301                 git reset --hard p4/depot/branch5 &&
302                 test_path_is_file file1 &&
303                 test_path_is_file file2 &&
304                 test_path_is_file file3 &&
305                 ! grep update file2 &&
306                 test_must_fail git show-ref --verify refs/git-p4-tmp
307         )
308 '
309
310 # Move branch3/file3 to branch4/file3 in a single changelist
311 test_expect_success 'git p4 submit to two branches in a single changelist' '
312         (
313                 cd "$cli" &&
314                 p4 integrate //depot/branch3/file3 //depot/branch4/file3 &&
315                 p4 delete //depot/branch3/file3 &&
316                 p4 submit -d "Move branch3/file3 to branch4/file3"
317         )
318 '
319
320 # Confirm that changes to two branches done in a single changelist
321 # are correctly imported by git p4
322 test_expect_success 'git p4 sync changes to two branches in the same changelist' '
323         test_when_finished cleanup_git &&
324         test_create_repo "$git" &&
325         (
326                 cd "$git" &&
327                 git config git-p4.branchList branch1:branch2 &&
328                 git config --add git-p4.branchList branch1:branch3 &&
329                 git config --add git-p4.branchList branch1:branch4 &&
330                 git config --add git-p4.branchList branch1:branch5 &&
331                 git p4 clone --dest=. --detect-branches //depot@all &&
332                 git log --all --graph --decorate --stat &&
333                 git reset --hard p4/depot/branch1 &&
334                 test_path_is_file file1 &&
335                 test_path_is_file file2 &&
336                 test_path_is_file file3 &&
337                 grep update file2 &&
338                 git reset --hard p4/depot/branch2 &&
339                 test_path_is_file file1 &&
340                 test_path_is_file file2 &&
341                 test_path_is_missing file3 &&
342                 ! grep update file2 &&
343                 git reset --hard p4/depot/branch3 &&
344                 test_path_is_file file1 &&
345                 test_path_is_file file2 &&
346                 test_path_is_missing file3 &&
347                 grep update file2 &&
348                 git reset --hard p4/depot/branch4 &&
349                 test_path_is_file file1 &&
350                 test_path_is_file file2 &&
351                 test_path_is_file file3 &&
352                 ! grep update file2 &&
353                 git reset --hard p4/depot/branch5 &&
354                 test_path_is_file file1 &&
355                 test_path_is_file file2 &&
356                 test_path_is_file file3 &&
357                 ! grep update file2 &&
358                 test_must_fail git show-ref --verify refs/git-p4-tmp
359         )
360 '
361
362 # Create a branch by integrating a single file
363 test_expect_success 'git p4 file subset branch' '
364         (
365                 cd "$cli" &&
366                 p4 integrate //depot/branch1/file1 //depot/branch6/file1 &&
367                 p4 submit -d "Integrate file1 alone from branch1 to branch6"
368         )
369 '
370
371 # Check if git p4 creates a new branch containing a single file,
372 # instead of keeping the old files from the original branch
373 test_expect_failure 'git p4 clone file subset branch' '
374         test_when_finished cleanup_git &&
375         test_create_repo "$git" &&
376         (
377                 cd "$git" &&
378                 git config git-p4.branchList branch1:branch2 &&
379                 git config --add git-p4.branchList branch1:branch3 &&
380                 git config --add git-p4.branchList branch1:branch4 &&
381                 git config --add git-p4.branchList branch1:branch5 &&
382                 git config --add git-p4.branchList branch1:branch6 &&
383                 git p4 clone --dest=. --detect-branches //depot@all &&
384                 git log --all --graph --decorate --stat &&
385                 git reset --hard p4/depot/branch1 &&
386                 test_path_is_file file1 &&
387                 test_path_is_file file2 &&
388                 test_path_is_file file3 &&
389                 grep update file2 &&
390                 git reset --hard p4/depot/branch2 &&
391                 test_path_is_file file1 &&
392                 test_path_is_file file2 &&
393                 test_path_is_missing file3 &&
394                 ! grep update file2 &&
395                 git reset --hard p4/depot/branch3 &&
396                 test_path_is_file file1 &&
397                 test_path_is_file file2 &&
398                 test_path_is_missing file3 &&
399                 grep update file2 &&
400                 git reset --hard p4/depot/branch4 &&
401                 test_path_is_file file1 &&
402                 test_path_is_file file2 &&
403                 test_path_is_file file3 &&
404                 ! grep update file2 &&
405                 git reset --hard p4/depot/branch5 &&
406                 test_path_is_file file1 &&
407                 test_path_is_file file2 &&
408                 test_path_is_file file3 &&
409                 ! grep update file2 &&
410                 git reset --hard p4/depot/branch6 &&
411                 test_path_is_file file1 &&
412                 test_path_is_missing file2 &&
413                 test_path_is_missing file3
414         )
415 '
416
417 # Check that excluded files are omitted during import
418 test_expect_success 'git p4 clone complex branches with excluded files' '
419         test_when_finished cleanup_git &&
420         test_create_repo "$git" &&
421         (
422                 cd "$git" &&
423                 git config git-p4.branchList branch1:branch2 &&
424                 git config --add git-p4.branchList branch1:branch3 &&
425                 git config --add git-p4.branchList branch1:branch4 &&
426                 git config --add git-p4.branchList branch1:branch5 &&
427                 git config --add git-p4.branchList branch1:branch6 &&
428                 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 &&
429                 git log --all --graph --decorate --stat &&
430                 git reset --hard p4/depot/branch1 &&
431                 test_path_is_file file1 &&
432                 test_path_is_missing file2 &&
433                 test_path_is_file file3 &&
434                 git reset --hard p4/depot/branch2 &&
435                 test_path_is_file file1 &&
436                 test_path_is_missing file2 &&
437                 test_path_is_missing file3 &&
438                 git reset --hard p4/depot/branch3 &&
439                 test_path_is_file file1 &&
440                 test_path_is_missing file2 &&
441                 test_path_is_missing file3 &&
442                 git reset --hard p4/depot/branch4 &&
443                 test_path_is_file file1 &&
444                 test_path_is_missing file2 &&
445                 test_path_is_file file3 &&
446                 git reset --hard p4/depot/branch5 &&
447                 test_path_is_file file1 &&
448                 test_path_is_missing file2 &&
449                 test_path_is_file file3 &&
450                 git reset --hard p4/depot/branch6 &&
451                 test_path_is_file file1 &&
452                 test_path_is_missing file2 &&
453                 test_path_is_missing file3
454         )
455 '
456
457 # From a report in http://stackoverflow.com/questions/11893688
458 # where --use-client-spec caused branch prefixes not to be removed;
459 # every file in git appeared into a subdirectory of the branch name.
460 test_expect_success 'use-client-spec detect-branches setup' '
461         rm -rf "$cli" &&
462         mkdir "$cli" &&
463         (
464                 cd "$cli" &&
465                 client_view "//depot/usecs/... //client/..." &&
466                 mkdir b1 &&
467                 echo b1/b1-file1 >b1/b1-file1 &&
468                 p4 add b1/b1-file1 &&
469                 p4 submit -d "b1/b1-file1" &&
470
471                 p4 integrate //depot/usecs/b1/... //depot/usecs/b2/... &&
472                 p4 submit -d "b1 -> b2" &&
473                 p4 branch -i <<-EOF &&
474                 Branch: b2
475                 View: //depot/usecs/b1/... //depot/usecs/b2/...
476                 EOF
477
478                 echo b2/b2-file2 >b2/b2-file2 &&
479                 p4 add b2/b2-file2 &&
480                 p4 submit -d "b2/b2-file2"
481         )
482 '
483
484 test_expect_success 'use-client-spec detect-branches files in top-level' '
485         test_when_finished cleanup_git &&
486         test_create_repo "$git" &&
487         (
488                 cd "$git" &&
489                 git p4 sync --detect-branches --use-client-spec //depot/usecs@all &&
490                 git checkout -b main p4/usecs/b1 &&
491                 test_path_is_file b1-file1 &&
492                 test_path_is_missing b2-file2 &&
493                 test_path_is_missing b1 &&
494                 test_path_is_missing b2 &&
495
496                 git checkout -b b2 p4/usecs/b2 &&
497                 test_path_is_file b1-file1 &&
498                 test_path_is_file b2-file2 &&
499                 test_path_is_missing b1 &&
500                 test_path_is_missing b2
501         )
502 '
503
504 test_expect_success 'use-client-spec detect-branches skips branches setup' '
505         (
506                 cd "$cli" &&
507
508                 p4 integrate //depot/usecs/b1/... //depot/usecs/b3/... &&
509                 p4 submit -d "b1 -> b3" &&
510                 p4 branch -i <<-EOF &&
511                 Branch: b3
512                 View: //depot/usecs/b1/... //depot/usecs/b3/...
513                 EOF
514
515                 echo b3/b3-file3_1 >b3/b3-file3_1 &&
516                 echo b3/b3-file3_2 >b3/b3-file3_2 &&
517                 p4 add b3/b3-file3_1 &&
518                 p4 add b3/b3-file3_2 &&
519                 p4 submit -d "b3/b3-file3_1 b3/b3-file3_2"
520         )
521 '
522
523 test_expect_success 'use-client-spec detect-branches skips branches' '
524         client_view "//depot/usecs/... //client/..." \
525                     "-//depot/usecs/b3/... //client/b3/..." &&
526         test_when_finished cleanup_git &&
527         test_create_repo "$git" &&
528         (
529                 cd "$git" &&
530                 git p4 sync --detect-branches --use-client-spec //depot/usecs@all &&
531                 test_must_fail git rev-parse refs/remotes/p4/usecs/b3
532         )
533 '
534
535 test_expect_success 'use-client-spec detect-branches skips files in branches' '
536         client_view "//depot/usecs/... //client/..." \
537                     "-//depot/usecs/b3/b3-file3_1 //client/b3/b3-file3_1" &&
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                 git checkout -b main p4/usecs/b3 &&
544                 test_path_is_file b1-file1 &&
545                 test_path_is_file b3-file3_2 &&
546                 test_path_is_missing b3-file3_1
547         )
548 '
549
550 test_expect_success 'restart p4d' '
551         stop_and_cleanup_p4d &&
552         start_p4d
553 '
554
555 #
556 # 1: //depot/branch1/base/file1
557 #    //depot/branch1/base/file2
558 #    //depot/branch1/base/dir/sub_file1
559 # 2: integrate //depot/branch1/base/... -> //depot/branch2/base/...
560 # 3: //depot/branch1/base/file3
561 # 4: //depot/branch1/base/file2 (edit)
562 # 5: integrate //depot/branch1/base/... -> //depot/branch3/base/...
563 #
564 # Note: the client view removes the "base" folder from the workspace
565 #       and moves sub_file1 one level up.
566 test_expect_success 'add simple p4 branches with common base folder on each branch' '
567         (
568                 cd "$cli" &&
569                 client_view "//depot/branch1/base/... //client/branch1/..." \
570                             "//depot/branch1/base/dir/sub_file1 //client/branch1/sub_file1" \
571                             "//depot/branch2/base/... //client/branch2/..." \
572                             "//depot/branch3/base/... //client/branch3/..." &&
573                 mkdir -p branch1 &&
574                 cd branch1 &&
575                 echo file1 >file1 &&
576                 echo file2 >file2 &&
577                 mkdir dir &&
578                 echo sub_file1 >sub_file1 &&
579                 p4 add file1 file2 sub_file1 &&
580                 p4 submit -d "Create branch1" &&
581                 p4 integrate //depot/branch1/base/... //depot/branch2/base/... &&
582                 p4 submit -d "Integrate branch2 from branch1" &&
583                 echo file3 >file3 &&
584                 p4 add file3 &&
585                 p4 submit -d "add file3 in branch1" &&
586                 p4 open file2 &&
587                 echo update >>file2 &&
588                 p4 submit -d "update file2 in branch1" &&
589                 p4 integrate //depot/branch1/base/... //depot/branch3/base/... &&
590                 p4 submit -d "Integrate branch3 from branch1"
591         )
592 '
593
594 # Configure branches through git-config and clone them.
595 # All files are tested to make sure branches were cloned correctly.
596 # Finally, make an update to branch1 on P4 side to check if it is imported
597 # correctly by git p4.
598 # git p4 is expected to use the client view to also not include the common
599 # "base" folder in the imported directory structure.
600 test_expect_success 'git p4 clone simple branches with base folder on server side' '
601         test_create_repo "$git" &&
602         (
603                 cd "$git" &&
604                 git config git-p4.branchList branch1:branch2 &&
605                 git config --add git-p4.branchList branch1:branch3 &&
606                 git p4 clone --dest=. --use-client-spec  --detect-branches //depot@all &&
607                 git log --all --graph --decorate --stat &&
608                 git reset --hard p4/depot/branch1 &&
609                 test -f file1 &&
610                 test -f file2 &&
611                 test -f file3 &&
612                 test -f sub_file1 &&
613                 grep update file2 &&
614                 git reset --hard p4/depot/branch2 &&
615                 test -f file1 &&
616                 test -f file2 &&
617                 test ! -f file3 &&
618                 test -f sub_file1 &&
619                 ! grep update file2 &&
620                 git reset --hard p4/depot/branch3 &&
621                 test -f file1 &&
622                 test -f file2 &&
623                 test -f file3 &&
624                 test -f sub_file1 &&
625                 grep update file2 &&
626                 cd "$cli" &&
627                 cd branch1 &&
628                 p4 edit file2 &&
629                 echo file2_ >>file2 &&
630                 p4 submit -d "update file2 in branch1" &&
631                 cd "$git" &&
632                 git reset --hard p4/depot/branch1 &&
633                 git p4 rebase &&
634                 grep file2_ file2
635         )
636 '
637
638 # Now update a file in one of the branches in git and submit to P4
639 test_expect_success 'Update a file in git side and submit to P4 using client view' '
640         test_when_finished cleanup_git &&
641         (
642                 cd "$git" &&
643                 git reset --hard p4/depot/branch1 &&
644                 echo "client spec" >> file1 &&
645                 git add -u . &&
646                 git commit -m "update file1 in branch1" &&
647                 git config git-p4.skipSubmitEdit true &&
648                 git p4 submit --verbose &&
649                 cd "$cli" &&
650                 p4 sync ... &&
651                 cd branch1 &&
652                 grep "client spec" file1
653         )
654 '
655
656 test_expect_success 'restart p4d (case folding enabled)' '
657         stop_and_cleanup_p4d &&
658         start_p4d -C1
659 '
660
661 #
662 # 1: //depot/main/mf1
663 # 2: integrate //depot/main/... -> //depot/branch1/...
664 # 3: //depot/main/mf2
665 # 4: //depot/BRANCH1/B1f3
666 # 5: //depot/branch1/b1f4
667 #
668 test_expect_success !CASE_INSENSITIVE_FS 'basic p4 branches for case folding' '
669         (
670                 cd "$cli" &&
671                 mkdir -p main &&
672
673                 echo mf1 >main/mf1 &&
674                 p4 add main/mf1 &&
675                 p4 submit -d "main/mf1" &&
676
677                 p4 integrate //depot/main/... //depot/branch1/... &&
678                 p4 submit -d "integrate main to branch1" &&
679
680                 echo mf2 >main/mf2 &&
681                 p4 add main/mf2 &&
682                 p4 submit -d "main/mf2" &&
683
684                 mkdir BRANCH1 &&
685                 echo B1f3 >BRANCH1/B1f3 &&
686                 p4 add BRANCH1/B1f3 &&
687                 p4 submit -d "BRANCH1/B1f3" &&
688
689                 echo b1f4 >branch1/b1f4 &&
690                 p4 add branch1/b1f4 &&
691                 p4 submit -d "branch1/b1f4"
692         )
693 '
694
695 # Check that files are properly split across branches when ignorecase is set
696 test_expect_success !CASE_INSENSITIVE_FS 'git p4 clone, branchList branch definition, ignorecase' '
697         test_when_finished cleanup_git &&
698         test_create_repo "$git" &&
699         (
700                 cd "$git" &&
701                 git config git-p4.branchList main:branch1 &&
702                 git config --type=bool core.ignoreCase true &&
703                 git p4 clone --dest=. --detect-branches //depot@all &&
704
705                 git log --all --graph --decorate --stat &&
706
707                 git reset --hard p4/master &&
708                 test_path_is_file mf1 &&
709                 test_path_is_file mf2 &&
710                 test_path_is_missing B1f3 &&
711                 test_path_is_missing b1f4 &&
712
713                 git reset --hard p4/depot/branch1 &&
714                 test_path_is_file mf1 &&
715                 test_path_is_missing mf2 &&
716                 test_path_is_file B1f3 &&
717                 test_path_is_file b1f4
718         )
719 '
720
721 # Check that files are properly split across branches when ignorecase is set, use-client-spec case
722 test_expect_success !CASE_INSENSITIVE_FS 'git p4 clone with client-spec, branchList branch definition, ignorecase' '
723         client_view "//depot/... //client/..." &&
724         test_when_finished cleanup_git &&
725         test_create_repo "$git" &&
726         (
727                 cd "$git" &&
728                 git config git-p4.branchList main:branch1 &&
729                 git config --type=bool core.ignoreCase true &&
730                 git p4 clone --dest=. --use-client-spec --detect-branches //depot@all &&
731
732                 git log --all --graph --decorate --stat &&
733
734                 git reset --hard p4/master &&
735                 test_path_is_file mf1 &&
736                 test_path_is_file mf2 &&
737                 test_path_is_missing B1f3 &&
738                 test_path_is_missing b1f4 &&
739
740                 git reset --hard p4/depot/branch1 &&
741                 test_path_is_file mf1 &&
742                 test_path_is_missing mf2 &&
743                 test_path_is_file B1f3 &&
744                 test_path_is_file b1f4
745         )
746 '
747
748 test_done