about summary refs log tree commit diff
path: root/t/t9821-git-p4-path-variations.sh
blob: ef80f1690bcb9ad153df900e277ef48ce8e4e62e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/sh

test_description='Clone repositories with path case variations'

. ./lib-git-p4.sh

test_expect_success 'start p4d with case folding enabled' '
	start_p4d -C1
'

test_expect_success 'Create a repo with path case variations' '
	client_view "//depot/... //client/..." &&
	(
		cd "$cli" &&

		mkdir -p Path/to &&
		>Path/to/File2.txt &&
		p4 add Path/to/File2.txt &&
		p4 submit -d "Add file2" &&
		rm -rf Path &&

		mkdir -p path/TO &&
		>path/TO/file1.txt &&
		p4 add path/TO/file1.txt &&
		p4 submit -d "Add file1" &&
		rm -rf path &&

		mkdir -p path/to &&
		>path/to/file3.txt &&
		p4 add path/to/file3.txt &&
		p4 submit -d "Add file3" &&
		rm -rf path &&

		mkdir -p x-outside-spec &&
		>x-outside-spec/file4.txt &&
		p4 add x-outside-spec/file4.txt &&
		p4 submit -d "Add file4" &&
		rm -rf x-outside-spec
	)
'

test_expect_success 'Clone root' '
	client_view "//depot/... //client/..." &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		git init . &&
		git config core.ignorecase false &&
		git p4 clone --use-client-spec --destination="$git" //depot &&
		# This method is used instead of "test -f" to ensure the case is
		# checked even if the test is executed on case-insensitive file systems.
		# All files are there as expected although the path cases look random.
		cat >expect <<-\EOF &&
		Path/to/File2.txt
		path/TO/file1.txt
		path/to/file3.txt
		x-outside-spec/file4.txt
		EOF
		git ls-files >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'Clone root (ignorecase)' '
	client_view "//depot/... //client/..." &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		git init . &&
		git config core.ignorecase true &&
		git p4 clone --use-client-spec --destination="$git" //depot &&
		# This method is used instead of "test -f" to ensure the case is
		# checked even if the test is executed on case-insensitive file systems.
		# All files are there as expected although the path cases look random.
		cat >expect <<-\EOF &&
		path/TO/File2.txt
		path/TO/file1.txt
		path/TO/file3.txt
		x-outside-spec/file4.txt
		EOF
		git ls-files >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'Clone root and ignore one file' '
	client_view \
		"//depot/... //client/..." \
		"-//depot/path/TO/file1.txt //client/path/TO/file1.txt" &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		git init . &&
		git config core.ignorecase false &&
		git p4 clone --use-client-spec --destination="$git" //depot &&
		# We ignore one file in the client spec and all path cases change from
		# "TO" to "to"!
		cat >expect <<-\EOF &&
		Path/to/File2.txt
		path/to/file3.txt
		x-outside-spec/file4.txt
		EOF
		git ls-files >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'Clone root and ignore one file (ignorecase)' '
	client_view \
		"//depot/... //client/..." \
		"-//depot/path/TO/file1.txt //client/path/TO/file1.txt" &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		git init . &&
		git config core.ignorecase true &&
		git p4 clone --use-client-spec --destination="$git" //depot &&
		# We ignore one file in the client spec and all path cases change from
		# "TO" to "to"!
		cat >expect <<-\EOF &&
		Path/to/File2.txt
		Path/to/file3.txt
		x-outside-spec/file4.txt
		EOF
		git ls-files >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'Clone path' '
	client_view "//depot/Path/... //client/..." &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		git init . &&
		git config core.ignorecase false &&
		git p4 clone --use-client-spec --destination="$git" //depot &&
		cat >expect <<-\EOF &&
		to/File2.txt
		EOF
		git ls-files >actual &&
		test_cmp expect actual
	)
'

test_expect_success 'Clone path (ignorecase)' '
	client_view "//depot/Path/... //client/..." &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		git init . &&
		git config core.ignorecase true &&
		git p4 clone --use-client-spec --destination="$git" //depot &&
		cat >expect <<-\EOF &&
		TO/File2.txt
		TO/file1.txt
		TO/file3.txt
		EOF
		git ls-files >actual &&
		test_cmp expect actual
	)
'

# It looks like P4 determines the path case based on the first file in
# lexicographical order. Please note the lower case "to" directory for all
# files triggered through the addition of "File0.txt".
test_expect_success 'Add a new file and clone path with new file (ignorecase)' '
	client_view "//depot/... //client/..." &&
	(
		cd "$cli" &&
		mkdir -p Path/to &&
		>Path/to/File0.txt &&
		p4 add Path/to/File0.txt &&
		p4 submit -d "Add file" &&
		rm -rf Path
	) &&

	client_view "//depot/Path/... //client/..." &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		git init . &&
		git config core.ignorecase true &&
		git p4 clone --use-client-spec --destination="$git" //depot &&
		cat >expect <<-\EOF &&
		to/File0.txt
		to/File2.txt
		to/file1.txt
		to/file3.txt
		EOF
		git ls-files >actual &&
		test_cmp expect actual
	)
'

test_done