From c8bae7493d2f2910b57f13ded012e86bdcfb0532 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:47:53 +0200 Subject: Adding upstream version 1:2.39.2. Signed-off-by: Daniel Baumann --- t/t9832-unshelve.sh | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100755 t/t9832-unshelve.sh (limited to 't/t9832-unshelve.sh') diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh new file mode 100755 index 0000000..6b3cb04 --- /dev/null +++ b/t/t9832-unshelve.sh @@ -0,0 +1,188 @@ +#!/bin/sh + +last_shelved_change () { + p4 changes -s shelved -m1 | cut -d " " -f 2 +} + +test_description='git p4 unshelve' + +. ./lib-git-p4.sh + +test_expect_success 'start p4d' ' + start_p4d +' + +test_expect_success 'init depot' ' + ( + cd "$cli" && + echo file1 >file1 && + p4 add file1 && + p4 submit -d "change 1" && + : >file_to_delete && + : >file_to_move && + p4 add file_to_delete && + p4 add file_to_move && + p4 submit -d "add files to delete" && + echo file_to_integrate >file_to_integrate && + p4 add file_to_integrate && + p4 submit -d "add file to integrate" + ) +' + +# Create an initial clone, with a commit unrelated to the P4 change +# on HEAD +test_expect_success 'initial clone' ' + git p4 clone --dest="$git" //depot/@all && + test_commit -C "$git" "unrelated" +' + +test_expect_success 'create shelved changelist' ' + ( + cd "$cli" && + p4 edit file1 && + echo "a change" >>file1 && + echo "new file" >file2 && + p4 add file2 && + p4 delete file_to_delete && + p4 edit file_to_move && + p4 move file_to_move moved_file && + p4 integrate file_to_integrate integrated_file && + p4 opened && + p4 shelve -i <actual && + grep -q "Further description" actual && + git cherry-pick refs/remotes/p4-unshelved/$change && + test_path_is_file file2 && + test_cmp file1 "$cli"/file1 && + test_cmp file2 "$cli"/file2 && + test_cmp file_to_integrate "$cli"/integrated_file && + test_path_is_missing file_to_delete && + test_path_is_missing file_to_move && + test_path_is_file moved_file + ) +' + +test_expect_success 'update shelved changelist and re-unshelve' ' + test_when_finished cleanup_git && + ( + cd "$cli" && + change=$(last_shelved_change) && + echo "file3" >file3 && + p4 add -c $change file3 && + p4 shelve -i -r <>file1 && + p4 submit -d "change:foo" && + p4 edit file1 && + echo "bar" >>file1 && + shelve_one_file //depot/file1 && + change=$(last_shelved_change) && + p4 describe -S $change >out.txt && + grep -q "Change to be unshelved" out.txt + ) +' + +# Now try to unshelve it. +test_expect_success 'try to unshelve the change' ' + test_when_finished cleanup_git && + ( + change=$(last_shelved_change) && + cd "$git" && + git p4 unshelve $change >out.txt && + grep -q "unshelved changelist $change" out.txt + ) +' + +# Specify the origin. Create 2 unrelated files, and check that +# we only get the one in HEAD~, not the one in HEAD. + +test_expect_success 'unshelve specifying the origin' ' + ( + cd "$cli" && + : >unrelated_file0 && + p4 add unrelated_file0 && + p4 submit -d "unrelated" && + : >unrelated_file1 && + p4 add unrelated_file1 && + p4 submit -d "unrelated" && + : >file_to_shelve && + p4 add file_to_shelve && + shelve_one_file //depot/file_to_shelve + ) && + test_when_finished cleanup_git && + git p4 clone --dest="$git" //depot/@all && + ( + cd "$git" && + change=$(last_shelved_change) && + git p4 unshelve --origin HEAD~ $change && + git checkout refs/remotes/p4-unshelved/$change && + test_path_is_file unrelated_file0 && + test_path_is_missing unrelated_file1 && + test_path_is_file file_to_shelve + ) +' + +test_done -- cgit v1.2.3