Skip to content

Commit 7a10bb3

Browse files
luked99gitster
authored andcommitted
git-p4: add failing test for shelved CL update involving move/copy
Updating a shelved P4 changelist where one or more files have been moved or copied does not work. Add a test for this. The problem is that P4 requires a complete list of the files being changed, and move/copy only includes the _source_ in the case of updating a shelved changelist. This results in errors from Perforce such as: //depot/src - needs tofile //depot/dst Submit aborted -- fix problems then use 'p4 submit -c 1234' Signed-off-by: Luke Diamand <[email protected]> Acked-by: Andrey Mazo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0d0ac38 commit 7a10bb3

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

t/t9807-git-p4-submit.sh

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ test_expect_success 'submit --shelve' '
500500
)
501501
'
502502

503+
last_shelve () {
504+
p4 -G changes -s shelved -m 1 //depot/... | marshal_dump change
505+
}
506+
503507
make_shelved_cl() {
504508
test_commit "$1" >/dev/null &&
505509
git p4 submit --origin HEAD^ --shelve >/dev/null &&
@@ -533,12 +537,59 @@ test_expect_success 'submit --update-shelve' '
533537
) &&
534538
(
535539
cd "$cli" &&
536-
change=$(p4 -G changes -s shelved -m 1 //depot/... | \
537-
marshal_dump change) &&
540+
change=$(last_shelve) &&
538541
p4 unshelve -c $change -s $change &&
539542
grep -q updated-line shelf.t &&
540543
p4 describe -S $change | grep added-file.t &&
541-
test_path_is_missing shelved-change-1.t
544+
test_path_is_missing shelved-change-1.t &&
545+
p4 revert ...
546+
)
547+
'
548+
549+
test_expect_failure 'update a shelve involving moved and copied files' '
550+
test_when_finished cleanup_git &&
551+
(
552+
cd "$cli" &&
553+
: >file_to_move &&
554+
p4 add file_to_move &&
555+
p4 submit -d "change1" &&
556+
p4 edit file_to_move &&
557+
echo change >>file_to_move &&
558+
p4 submit -d "change2" &&
559+
p4 opened
560+
) &&
561+
git p4 clone --dest="$git" //depot &&
562+
(
563+
cd "$git" &&
564+
git config git-p4.detectCopies true &&
565+
git config git-p4.detectRenames true &&
566+
git config git-p4.skipSubmitEdit true &&
567+
mkdir moved &&
568+
cp file_to_move copy_of_file &&
569+
git add copy_of_file &&
570+
git mv file_to_move moved/ &&
571+
git commit -m "rename a file" &&
572+
git p4 submit -M --shelve --origin HEAD^ &&
573+
: >new_file &&
574+
git add new_file &&
575+
git commit --amend &&
576+
git show --stat HEAD &&
577+
change=$(last_shelve) &&
578+
git p4 submit -M --update-shelve $change --commit HEAD
579+
) &&
580+
(
581+
cd "$cli" &&
582+
change=$(last_shelve) &&
583+
echo change=$change &&
584+
p4 unshelve -s $change &&
585+
p4 submit -d "Testing update-shelve" &&
586+
test_path_is_file copy_of_file &&
587+
test_path_is_file moved/file_to_move &&
588+
test_path_is_missing file_to_move &&
589+
test_path_is_file new_file &&
590+
echo "unshelved and submitted change $change" &&
591+
p4 changes moved/file_to_move | grep "Testing update-shelve" &&
592+
p4 changes copy_of_file | grep "Testing update-shelve"
542593
)
543594
'
544595

0 commit comments

Comments
 (0)