combine-diff: coalesce lost lines optimally
[gitweb.git] / t / t9807-git-p4-submit.sh
index 9394fd4e9b5bd7eedc1f3d0552aa71d429b64308..1fb7bc7cf98bdbdf89491c687e6347cda673d720 100755 (executable)
@@ -17,6 +17,16 @@ test_expect_success 'init depot' '
        )
 '
 
+test_expect_failure 'is_cli_file_writeable function' '
+       (
+               cd "$cli" &&
+               echo a >a &&
+               is_cli_file_writeable a &&
+               ! is_cli_file_writeable file1 &&
+               rm a
+       )
+'
+
 test_expect_success 'submit with no client dir' '
        test_when_finished cleanup_git &&
        git p4 clone --dest="$git" //depot &&
@@ -54,6 +64,47 @@ test_expect_success 'submit --origin' '
        )
 '
 
+test_expect_success 'submit --dry-run' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$git" &&
+               test_commit "dry-run1" &&
+               test_commit "dry-run2" &&
+               git p4 submit --dry-run >out &&
+               test_i18ngrep "Would apply" out
+       ) &&
+       (
+               cd "$cli" &&
+               test_path_is_missing "dry-run1.t" &&
+               test_path_is_missing "dry-run2.t"
+       )
+'
+
+test_expect_success 'submit --dry-run --export-labels' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$git" &&
+               echo dry-run1 >dry-run1 &&
+               git add dry-run1 &&
+               git commit -m "dry-run1" dry-run1 &&
+               git config git-p4.skipSubmitEdit true &&
+               git p4 submit &&
+               echo dry-run2 >dry-run2 &&
+               git add dry-run2 &&
+               git commit -m "dry-run2" dry-run2 &&
+               git tag -m "dry-run-tag1" dry-run-tag1 HEAD^ &&
+               git p4 submit --dry-run --export-labels >out &&
+               test_i18ngrep "Would create p4 label" out
+       ) &&
+       (
+               cd "$cli" &&
+               test_path_is_file "dry-run1" &&
+               test_path_is_missing "dry-run2"
+       )
+'
+
 test_expect_success 'submit with allowSubmit' '
        test_when_finished cleanup_git &&
        git p4 clone --dest="$git" //depot &&
@@ -159,7 +210,7 @@ test_expect_success 'submit copy' '
        (
                cd "$cli" &&
                test_path_is_file file5.ta &&
-               test ! -w file5.ta
+               ! is_cli_file_writeable file5.ta
        )
 '
 
@@ -178,7 +229,7 @@ test_expect_success 'submit rename' '
                cd "$cli" &&
                test_path_is_missing file6.t &&
                test_path_is_file file6.ta &&
-               test ! -w file6.ta
+               ! is_cli_file_writeable file6.ta
        )
 '
 
@@ -334,6 +385,30 @@ test_expect_success 'description with Jobs section and bogus following text' '
                make_job $(cat jobname) &&
                test_must_fail git p4 submit 2>err &&
                test_i18ngrep "Unknown field name" err
+       ) &&
+       (
+               cd "$cli" &&
+               p4 revert desc6 &&
+               rm desc6
+       )
+'
+
+test_expect_success 'submit --prepare-p4-only' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$git" &&
+               echo prep-only-add >prep-only-add &&
+               git add prep-only-add &&
+               git commit -m "prep only add" &&
+               git p4 submit --prepare-p4-only >out &&
+               test_i18ngrep "prepared for submission" out &&
+               test_i18ngrep "must be deleted" out
+       ) &&
+       (
+               cd "$cli" &&
+               test_path_is_file prep-only-add &&
+               p4 fstat -T action prep-only-add | grep -w add
        )
 '