aboutsummaryrefslogtreecommitdiff
path: root/t/t9812-git-p4-wildcards.sh
blob: 0206771fbb91b734a626e628b21786805ebcfa22 (plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/sh

test_description='git p4 wildcards'

. ./lib-git-p4.sh

test_expect_success 'start p4d' '
	start_p4d
'

test_expect_success 'add p4 files with wildcards in the names' '
	(
		cd "$cli" &&
		printf "file2\nhas\nsome\nrandom\ntext\n" >file2 &&
		p4 add file2 &&
		echo file-wild-hash >file-wild#hash &&
		if test_have_prereq !MINGW,!CYGWIN
		then
			echo file-wild-star >file-wild\*star
		fi &&
		echo file-wild-at >file-wild@at &&
		echo file-wild-percent >file-wild%percent &&
		p4 add -f file-wild* &&
		p4 submit -d "file wildcards"
	)
'

test_expect_success 'wildcard files git p4 clone' '
	git p4 clone --dest="$git" //depot &&
	test_when_finished cleanup_git &&
	(
		cd "$git" &&
		test -f file-wild#hash &&
		if test_have_prereq !MINGW,!CYGWIN
		then
			test -f file-wild\*star
		fi &&
		test -f file-wild@at &&
		test -f file-wild%percent
	)
'

test_expect_success 'wildcard files submit back to p4, add' '
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot &&
	(
		cd "$git" &&
		echo git-wild-hash >git-wild#hash &&
		if test_have_prereq !MINGW,!CYGWIN
		then
			echo git-wild-star >git-wild\*star
		fi &&
		echo git-wild-at >git-wild@at &&
		echo git-wild-percent >git-wild%percent &&
		git add git-wild* &&
		git commit -m "add some wildcard filenames" &&
		git config git-p4.skipSubmitEdit true &&
		git p4 submit
	) &&
	(
		cd "$cli" &&
		test_path_is_file git-wild#hash &&
		if test_have_prereq !MINGW,!CYGWIN
		then
			test_path_is_file git-wild\*star
		fi &&
		test_path_is_file git-wild@at &&
		test_path_is_file git-wild%percent
	)
'

test_expect_success 'wildcard files submit back to p4, modify' '
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot &&
	(
		cd "$git" &&
		echo new-line >>git-wild#hash &&
		if test_have_prereq !MINGW,!CYGWIN
		then
			echo new-line >>git-wild\*star
		fi &&
		echo new-line >>git-wild@at &&
		echo new-line >>git-wild%percent &&
		git add git-wild* &&
		git commit -m "modify the wildcard files" &&
		git config git-p4.skipSubmitEdit true &&
		git p4 submit
	) &&
	(
		cd "$cli" &&
		test_line_count = 2 git-wild#hash &&
		if test_have_prereq !MINGW,!CYGWIN
		then
			test_line_count = 2 git-wild\*star
		fi &&
		test_line_count = 2 git-wild@at &&
		test_line_count = 2 git-wild%percent
	)
'

test_expect_success 'wildcard files submit back to p4, copy' '
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot &&
	(
		cd "$git" &&
		cp file2 git-wild-cp#hash &&
		git add git-wild-cp#hash &&
		cp git-wild#hash file-wild-3 &&
		git add file-wild-3 &&
		git commit -m "wildcard copies" &&
		git config git-p4.detectCopies true &&
		git config git-p4.detectCopiesHarder true &&
		git config git-p4.skipSubmitEdit true &&
		git p4 submit
	) &&
	(
		cd "$cli" &&
		test_path_is_file git-wild-cp#hash &&
		test_path_is_file file-wild-3
	)
'

test_expect_success 'wildcard files submit back to p4, rename' '
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot &&
	(
		cd "$git" &&
		git mv git-wild@at file-wild-4 &&
		git mv file-wild-3 git-wild-cp%percent &&
		git commit -m "wildcard renames" &&
		git config git-p4.detectRenames true &&
		git config git-p4.skipSubmitEdit true &&
		git p4 submit
	) &&
	(
		cd "$cli" &&
		test_path_is_missing git-wild@at &&
		test_path_is_file git-wild-cp%percent
	)
'

test_expect_success 'wildcard files submit back to p4, delete' '
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot &&
	(
		cd "$git" &&
		git rm git-wild* &&
		git commit -m "delete the wildcard files" &&
		git config git-p4.skipSubmitEdit true &&
		git p4 submit
	) &&
	(
		cd "$cli" &&
		test_path_is_missing git-wild#hash &&
		if test_have_prereq !MINGW,!CYGWIN
		then
			test_path_is_missing git-wild\*star
		fi &&
		test_path_is_missing git-wild@at &&
		test_path_is_missing git-wild%percent
	)
'

test_expect_success 'p4 deleted a wildcard file' '
	(
		cd "$cli" &&
		echo "wild delete test" >wild@delete &&
		p4 add -f wild@delete &&
		p4 submit -d "add wild@delete"
	) &&
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot &&
	(
		cd "$git" &&
		test_path_is_file wild@delete
	) &&
	(
		cd "$cli" &&
		# must use its encoded name
		p4 delete wild%40delete &&
		p4 submit -d "delete wild@delete"
	) &&
	(
		cd "$git" &&
		git p4 sync &&
		git merge --ff-only p4/master &&
		test_path_is_missing wild@delete
	)
'

test_expect_success 'wildcard files requiring keyword scrub' '
	(
		cd "$cli" &&
		cat <<-\EOF >scrub@wild &&
		$Id$
		line2
		EOF
		p4 add -t text+k -f scrub@wild &&
		p4 submit -d "scrub at wild"
	) &&
	test_when_finished cleanup_git &&
	git p4 clone --dest="$git" //depot &&
	(
		cd "$git" &&
		git config git-p4.skipSubmitEdit true &&
		git config git-p4.attemptRCSCleanup true &&
		sed "s/^line2/line2 edit/" <scrub@wild >scrub@wild.tmp &&
		mv -f scrub@wild.tmp scrub@wild &&
		git commit -m "scrub at wild line2 edit" scrub@wild &&
		git p4 submit
	)
'

test_expect_success 'kill p4d' '
	kill_p4d
'

test_done