2011-12-10 00:48:15 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-04-09 02:18:02 +02:00
|
|
|
test_description='git p4 submit'
|
2011-12-10 00:48:15 +01:00
|
|
|
|
|
|
|
. ./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"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submit with no client dir' '
|
|
|
|
test_when_finished cleanup_git &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot &&
|
2011-12-10 00:48:15 +01:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
echo file2 >file2 &&
|
|
|
|
git add file2 &&
|
|
|
|
git commit -m "git commit 2" &&
|
|
|
|
rm -rf "$cli" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 submit
|
2012-04-30 02:57:14 +02:00
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
test_path_is_file file1 &&
|
|
|
|
test_path_is_file file2
|
2011-12-10 00:48:15 +01:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-12-25 03:07:40 +01:00
|
|
|
# make two commits, but tell it to apply only from HEAD^
|
|
|
|
test_expect_success 'submit --origin' '
|
|
|
|
test_when_finished cleanup_git &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot &&
|
2011-12-25 03:07:40 +01:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
test_commit "file3" &&
|
|
|
|
test_commit "file4" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 submit --origin=HEAD^
|
2011-12-25 03:07:40 +01:00
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
test_path_is_missing "file3.t" &&
|
|
|
|
test_path_is_file "file4.t"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submit with allowSubmit' '
|
|
|
|
test_when_finished cleanup_git &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot &&
|
2011-12-25 03:07:40 +01:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
test_commit "file5" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
|
|
|
git config git-p4.allowSubmit "nobranch" &&
|
2012-04-09 02:18:02 +02:00
|
|
|
test_must_fail git p4 submit &&
|
2011-12-25 03:07:40 +01:00
|
|
|
git config git-p4.allowSubmit "nobranch,master" &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 submit
|
2011-12-25 03:07:40 +01:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submit with master branch name from argv' '
|
|
|
|
test_when_finished cleanup_git &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 clone --dest="$git" //depot &&
|
2011-12-25 03:07:40 +01:00
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
test_commit "file6" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
2012-04-09 02:18:02 +02:00
|
|
|
test_must_fail git p4 submit nobranch &&
|
2011-12-25 03:07:40 +01:00
|
|
|
git branch otherbranch &&
|
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
test_commit "file7" &&
|
2012-04-09 02:18:02 +02:00
|
|
|
git p4 submit otherbranch
|
2011-12-25 03:07:40 +01:00
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
test_path_is_file "file6.t" &&
|
|
|
|
test_path_is_missing "file7.t"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2012-04-30 02:57:15 +02:00
|
|
|
#
|
|
|
|
# Basic submit tests, the five handled cases
|
|
|
|
#
|
|
|
|
|
|
|
|
test_expect_success 'submit modify' '
|
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
git p4 clone --dest="$git" //depot &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
|
|
|
echo line >>file1 &&
|
|
|
|
git add file1 &&
|
|
|
|
git commit -m file1 &&
|
|
|
|
git p4 submit
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
test_path_is_file file1 &&
|
|
|
|
test_line_count = 2 file1
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submit add' '
|
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
git p4 clone --dest="$git" //depot &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
|
|
|
echo file13 >file13 &&
|
|
|
|
git add file13 &&
|
|
|
|
git commit -m file13 &&
|
|
|
|
git p4 submit
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
test_path_is_file file13
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submit delete' '
|
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
git p4 clone --dest="$git" //depot &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
|
|
|
git rm file4.t &&
|
|
|
|
git commit -m "delete file4.t" &&
|
|
|
|
git p4 submit
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
test_path_is_missing file4.t
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submit copy' '
|
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
git p4 clone --dest="$git" //depot &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
|
|
|
git config git-p4.detectCopies true &&
|
|
|
|
git config git-p4.detectCopiesHarder true &&
|
|
|
|
cp file5.t file5.ta &&
|
|
|
|
git add file5.ta &&
|
|
|
|
git commit -m "copy to file5.ta" &&
|
|
|
|
git p4 submit
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
2012-04-30 02:57:16 +02:00
|
|
|
test_path_is_file file5.ta &&
|
|
|
|
test ! -w file5.ta
|
2012-04-30 02:57:15 +02:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submit rename' '
|
|
|
|
test_when_finished cleanup_git &&
|
|
|
|
git p4 clone --dest="$git" //depot &&
|
|
|
|
(
|
|
|
|
cd "$git" &&
|
|
|
|
git config git-p4.skipSubmitEdit true &&
|
|
|
|
git config git-p4.detectRenames true &&
|
|
|
|
git mv file6.t file6.ta &&
|
|
|
|
git commit -m "rename file6.t to file6.ta" &&
|
|
|
|
git p4 submit
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd "$cli" &&
|
|
|
|
test_path_is_missing file6.t &&
|
2012-04-30 02:57:16 +02:00
|
|
|
test_path_is_file file6.ta &&
|
|
|
|
test ! -w file6.ta
|
2012-04-30 02:57:15 +02:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2011-12-10 00:48:15 +01:00
|
|
|
test_expect_success 'kill p4d' '
|
|
|
|
kill_p4d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|