Imported Upstream version 2.17.0
[platform/upstream/git.git] / t / t9800-git-p4-basic.sh
index 8c59796..4849edc 100755 (executable)
@@ -30,6 +30,11 @@ test_expect_success 'basic git p4 clone' '
        )
 '
 
+test_expect_success 'depot typo error' '
+       test_must_fail git p4 clone --dest="$git" /depot 2>errs &&
+       grep "Depot paths must start with" errs
+'
+
 test_expect_success 'git p4 clone @all' '
        git p4 clone --dest="$git" //depot@all &&
        test_when_finished cleanup_git &&
@@ -126,6 +131,64 @@ test_expect_success 'clone two dirs, @all, conflicting files' '
        )
 '
 
+test_expect_success 'clone two dirs, each edited by submit, single git commit' '
+       (
+               cd "$cli" &&
+               echo sub1/f4 >sub1/f4 &&
+               p4 add sub1/f4 &&
+               echo sub2/f4 >sub2/f4 &&
+               p4 add sub2/f4 &&
+               p4 submit -d "sub1/f4 and sub2/f4"
+       ) &&
+       git p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&
+       test_when_finished cleanup_git &&
+       (
+               cd "$git" &&
+               git ls-files >lines &&
+               test_line_count = 4 lines &&
+               git log --oneline p4/master >lines &&
+               test_line_count = 5 lines
+       )
+'
+
+revision_ranges="2000/01/01,#head \
+                1,2080/01/01 \
+                2000/01/01,2080/01/01 \
+                2000/01/01,1000 \
+                1,1000"
+
+test_expect_success 'clone using non-numeric revision ranges' '
+       test_when_finished cleanup_git &&
+       for r in $revision_ranges
+       do
+               rm -fr "$git" &&
+               test ! -d "$git" &&
+               git p4 clone --dest="$git" //depot@$r &&
+               (
+                       cd "$git" &&
+                       git ls-files >lines &&
+                       test_line_count = 8 lines
+               )
+       done
+'
+
+test_expect_success 'clone with date range, excluding some changes' '
+       test_when_finished cleanup_git &&
+       before=$(date +%Y/%m/%d:%H:%M:%S) &&
+       sleep 2 &&
+       (
+               cd "$cli" &&
+               :>date_range_test &&
+               p4 add date_range_test &&
+               p4 submit -d "Adding file"
+       ) &&
+       git p4 clone --dest="$git" //depot@1,$before &&
+       (
+               cd "$git" &&
+               test_path_is_missing date_range_test
+       )
+'
+
 test_expect_success 'exit when p4 fails to produce marshaled output' '
        mkdir badp4dir &&
        test_when_finished "rm badp4dir/p4 && rmdir badp4dir" &&
@@ -140,7 +203,7 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '
                test_expect_code 1 git p4 clone --dest="$git" //depot >errs 2>&1
        ) &&
        cat errs &&
-       ! test_i18ngrep Traceback errs
+       test_i18ngrep ! Traceback errs
 '
 
 # Hide a file from p4d, make sure we catch its complaint.  This won't fail in
@@ -160,9 +223,12 @@ test_expect_success 'clone --bare should make a bare repository' '
        test_when_finished cleanup_git &&
        (
                cd "$git" &&
-               test ! -d .git &&
-               bare=`git config --get core.bare` &&
-               test "$bare" = true
+               test_path_is_missing .git &&
+               git config --get --bool core.bare true &&
+               git rev-parse --verify refs/remotes/p4/master &&
+               git rev-parse --verify refs/remotes/p4/HEAD &&
+               git rev-parse --verify refs/heads/master &&
+               git rev-parse --verify HEAD
        )
 '
 
@@ -195,6 +261,42 @@ test_expect_success 'unresolvable host in P4PORT should display error' '
        )
 '
 
+test_expect_success 'submit from detached head' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$git" &&
+               git checkout p4/master &&
+               >detached_head_test &&
+               git add detached_head_test &&
+               git commit -m "add detached_head" &&
+               git config git-p4.skipSubmitEdit true &&
+               git p4 submit &&
+               git p4 rebase &&
+               git log p4/master | grep detached_head
+       )
+'
+
+test_expect_success 'submit from worktree' '
+       test_when_finished cleanup_git &&
+       git p4 clone --dest="$git" //depot &&
+       (
+               cd "$git" &&
+               git worktree add ../worktree-test
+       ) &&
+       (
+               cd "$git/../worktree-test" &&
+               test_commit "worktree-commit" &&
+               git config git-p4.skipSubmitEdit true &&
+               git p4 submit
+       ) &&
+       (
+               cd "$cli" &&
+               p4 sync &&
+               test_path_is_file worktree-commit.t
+       )
+'
+
 test_expect_success 'kill p4d' '
        kill_p4d
 '