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