Skip to content

Commit c5665ef

Browse files
vhdagitster
authored andcommitted
git-p4: Add test case for complex branch import
Check if branches created from old changelists are correctly imported. Also included some updates to simple branch test so that both are coherent in respect to each other. Signed-off-by: Vitor Antunes <[email protected]> Acked-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fed2369 commit c5665ef

File tree

1 file changed

+87
-7
lines changed

1 file changed

+87
-7
lines changed

t/t9801-git-p4-branch.sh

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ test_expect_success 'add simple p4 branches' '
172172
echo file1 >file1 &&
173173
echo file2 >file2 &&
174174
p4 add file1 file2 &&
175-
p4 submit -d "branch1" &&
175+
p4 submit -d "Create branch1" &&
176176
p4 integrate //depot/branch1/... //depot/branch2/... &&
177-
p4 submit -d "branch2" &&
177+
p4 submit -d "Integrate branch2 from branch1" &&
178178
echo file3 >file3 &&
179179
p4 add file3 &&
180180
p4 submit -d "add file3 in branch1" &&
181181
p4 open file2 &&
182182
echo update >>file2 &&
183183
p4 submit -d "update file2 in branch1" &&
184184
p4 integrate //depot/branch1/... //depot/branch3/... &&
185-
p4 submit -d "branch3"
185+
p4 submit -d "Integrate branch3 from branch1"
186186
)
187187
'
188188

@@ -203,17 +203,17 @@ test_expect_success 'git-p4 clone simple branches' '
203203
test -f file1 &&
204204
test -f file2 &&
205205
test -f file3 &&
206-
grep -q update file2 &&
206+
grep update file2 &&
207207
git reset --hard p4/depot/branch2 &&
208208
test -f file1 &&
209209
test -f file2 &&
210210
test ! -f file3 &&
211-
test_must_fail grep -q update file2 &&
211+
test_must_fail grep update file2 &&
212212
git reset --hard p4/depot/branch3 &&
213213
test -f file1 &&
214214
test -f file2 &&
215215
test -f file3 &&
216-
grep -q update file2 &&
216+
grep update file2 &&
217217
cd "$cli" &&
218218
cd branch1 &&
219219
p4 edit file2 &&
@@ -222,7 +222,87 @@ test_expect_success 'git-p4 clone simple branches' '
222222
cd "$git" &&
223223
git reset --hard p4/depot/branch1 &&
224224
"$GITP4" rebase &&
225-
grep -q file2_ file2
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+
test_when_finished cleanup_git &&
253+
test_create_repo "$git" &&
254+
(
255+
cd "$cli" &&
256+
changelist=$(p4 changes -m1 //depot/... | cut -d" " -f2) &&
257+
changelist=$(($changelist - 5)) &&
258+
p4 integrate //depot/branch1/...@$changelist //depot/branch4/... &&
259+
p4 submit -d "Integrate branch4 from branch1@${changelist}" &&
260+
changelist=$(($changelist + 2)) &&
261+
p4 integrate //depot/branch1/...@$changelist //depot/branch5/... &&
262+
p4 submit -d "Integrate branch5 from branch1@${changelist}"
263+
)
264+
'
265+
266+
# Configure branches through git-config and clone them. git-p4 will only be able
267+
# to clone the original structure if it is able to detect the origin changelist
268+
# of each branch.
269+
test_expect_success 'git-p4 clone complex branches' '
270+
test_when_finished cleanup_git &&
271+
test_create_repo "$git" &&
272+
(
273+
cd "$git" &&
274+
git config git-p4.branchList branch1:branch2 &&
275+
git config --add git-p4.branchList branch1:branch3 &&
276+
git config --add git-p4.branchList branch1:branch4 &&
277+
git config --add git-p4.branchList branch1:branch5 &&
278+
"$GITP4" clone --dest=. --detect-branches //depot@all &&
279+
git log --all --graph --decorate --stat &&
280+
git reset --hard p4/depot/branch1 &&
281+
test_path_is_file file1 &&
282+
test_path_is_file file2 &&
283+
test_path_is_file file3 &&
284+
grep update file2 &&
285+
git reset --hard p4/depot/branch2 &&
286+
test_path_is_file file1 &&
287+
test_path_is_file file2 &&
288+
test_path_is_missing file3 &&
289+
test_must_fail grep update file2 &&
290+
git reset --hard p4/depot/branch3 &&
291+
test_path_is_file file1 &&
292+
test_path_is_file file2 &&
293+
test_path_is_file file3 &&
294+
grep update file2 &&
295+
git reset --hard p4/depot/branch4 &&
296+
test_path_is_file file1 &&
297+
test_path_is_file file2 &&
298+
test_path_is_missing file3 &&
299+
test_must_fail grep update file2 &&
300+
git reset --hard p4/depot/branch5 &&
301+
test_path_is_file file1 &&
302+
test_path_is_file file2 &&
303+
test_path_is_file file3 &&
304+
test_must_fail grep update file2 &&
305+
test_path_is_missing .git/git-p4-tmp
226306
)
227307
'
228308

0 commit comments

Comments
 (0)