The eleventh batch
[alt-git.git] / t / t9821-git-p4-path-variations.sh
blob49691c53dadddb85c7dbaf0e0a52336d2b91d349
1 #!/bin/sh
3 test_description='Clone repositories with path case variations'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./lib-git-p4.sh
8 test_expect_success 'start p4d with case folding enabled' '
9 start_p4d -C1
12 test_expect_success 'Create a repo with path case variations' '
13 client_view "//depot/... //client/..." &&
15 cd "$cli" &&
17 mkdir -p Path/to &&
18 >Path/to/File2.txt &&
19 p4 add Path/to/File2.txt &&
20 p4 submit -d "Add file2" &&
21 rm -rf Path &&
23 mkdir -p path/TO &&
24 >path/TO/file1.txt &&
25 p4 add path/TO/file1.txt &&
26 p4 submit -d "Add file1" &&
27 rm -rf path &&
29 mkdir -p path/to &&
30 >path/to/file3.txt &&
31 p4 add path/to/file3.txt &&
32 p4 submit -d "Add file3" &&
33 rm -rf path &&
35 mkdir -p x-outside-spec &&
36 >x-outside-spec/file4.txt &&
37 p4 add x-outside-spec/file4.txt &&
38 p4 submit -d "Add file4" &&
39 rm -rf x-outside-spec
43 test_expect_success 'Clone root' '
44 client_view "//depot/... //client/..." &&
45 test_when_finished cleanup_git &&
47 cd "$git" &&
48 git init . &&
49 git config core.ignorecase false &&
50 git p4 clone --use-client-spec --destination="$git" //depot &&
51 # This method is used instead of "test -f" to ensure the case is
52 # checked even if the test is executed on case-insensitive file systems.
53 # All files are there as expected although the path cases look random.
54 cat >expect <<-\EOF &&
55 Path/to/File2.txt
56 path/TO/file1.txt
57 path/to/file3.txt
58 x-outside-spec/file4.txt
59 EOF
60 git ls-files >actual &&
61 test_cmp expect actual
65 test_expect_success 'Clone root (ignorecase)' '
66 client_view "//depot/... //client/..." &&
67 test_when_finished cleanup_git &&
69 cd "$git" &&
70 git init . &&
71 git config core.ignorecase true &&
72 git p4 clone --use-client-spec --destination="$git" //depot &&
73 # This method is used instead of "test -f" to ensure the case is
74 # checked even if the test is executed on case-insensitive file systems.
75 # All files are there as expected although the path cases look random.
76 cat >expect <<-\EOF &&
77 path/TO/File2.txt
78 path/TO/file1.txt
79 path/TO/file3.txt
80 x-outside-spec/file4.txt
81 EOF
82 git ls-files >actual &&
83 test_cmp expect actual
87 test_expect_success 'Clone root and ignore one file' '
88 client_view \
89 "//depot/... //client/..." \
90 "-//depot/path/TO/file1.txt //client/path/TO/file1.txt" &&
91 test_when_finished cleanup_git &&
93 cd "$git" &&
94 git init . &&
95 git config core.ignorecase false &&
96 git p4 clone --use-client-spec --destination="$git" //depot &&
97 # We ignore one file in the client spec and all path cases change from
98 # "TO" to "to"!
99 cat >expect <<-\EOF &&
100 Path/to/File2.txt
101 path/to/file3.txt
102 x-outside-spec/file4.txt
104 git ls-files >actual &&
105 test_cmp expect actual
109 test_expect_success 'Clone root and ignore one file (ignorecase)' '
110 client_view \
111 "//depot/... //client/..." \
112 "-//depot/path/TO/file1.txt //client/path/TO/file1.txt" &&
113 test_when_finished cleanup_git &&
115 cd "$git" &&
116 git init . &&
117 git config core.ignorecase true &&
118 git p4 clone --use-client-spec --destination="$git" //depot &&
119 # We ignore one file in the client spec and all path cases change from
120 # "TO" to "to"!
121 cat >expect <<-\EOF &&
122 Path/to/File2.txt
123 Path/to/file3.txt
124 x-outside-spec/file4.txt
126 git ls-files >actual &&
127 test_cmp expect actual
131 test_expect_success 'Clone path' '
132 client_view "//depot/Path/... //client/..." &&
133 test_when_finished cleanup_git &&
135 cd "$git" &&
136 git init . &&
137 git config core.ignorecase false &&
138 git p4 clone --use-client-spec --destination="$git" //depot &&
139 cat >expect <<-\EOF &&
140 to/File2.txt
142 git ls-files >actual &&
143 test_cmp expect actual
147 test_expect_success 'Clone path (ignorecase)' '
148 client_view "//depot/Path/... //client/..." &&
149 test_when_finished cleanup_git &&
151 cd "$git" &&
152 git init . &&
153 git config core.ignorecase true &&
154 git p4 clone --use-client-spec --destination="$git" //depot &&
155 cat >expect <<-\EOF &&
156 TO/File2.txt
157 TO/file1.txt
158 TO/file3.txt
160 git ls-files >actual &&
161 test_cmp expect actual
165 # It looks like P4 determines the path case based on the first file in
166 # lexicographical order. Please note the lower case "to" directory for all
167 # files triggered through the addition of "File0.txt".
168 test_expect_success 'Add a new file and clone path with new file (ignorecase)' '
169 client_view "//depot/... //client/..." &&
171 cd "$cli" &&
172 mkdir -p Path/to &&
173 >Path/to/File0.txt &&
174 p4 add Path/to/File0.txt &&
175 p4 submit -d "Add file" &&
176 rm -rf Path
177 ) &&
179 client_view "//depot/Path/... //client/..." &&
180 test_when_finished cleanup_git &&
182 cd "$git" &&
183 git init . &&
184 git config core.ignorecase true &&
185 git p4 clone --use-client-spec --destination="$git" //depot &&
186 cat >expect <<-\EOF &&
187 to/File0.txt
188 to/File2.txt
189 to/file1.txt
190 to/file3.txt
192 git ls-files >actual &&
193 test_cmp expect actual
197 test_done