Merge branch 'tb/pretty-format-cd-date-format'
[gitweb.git] / t / t9809-git-p4-client-view.sh
index 796b02c7f34ebcc385c228ccb5751ed89db8c6f1..897b3c3034efcab3af88d8eddc4670e274361dd5 100755 (executable)
@@ -8,23 +8,6 @@ test_expect_success 'start p4d' '
        start_p4d
 '
 
-#
-# Construct a client with this list of View lines
-#
-client_view() {
-       (
-               cat <<-EOF &&
-               Client: client
-               Description: client
-               Root: $cli
-               View:
-               EOF
-               for arg ; do
-                       printf "\t$arg\n"
-               done
-       ) | p4 client -i
-}
-
 #
 # Verify these files exist, exactly.  Caller creates
 # a list of files in file "files".
@@ -93,28 +76,28 @@ test_expect_success 'init depot' '
 '
 
 # double % for printf
-test_expect_success 'unsupported view wildcard %%n' '
+test_expect_success 'view wildcard %%n' '
        client_view "//depot/%%%%1/sub/... //client/sub/%%%%1/..." &&
        test_when_finished cleanup_git &&
-       test_must_fail git p4 clone --use-client-spec --dest="$git" //depot
+       git p4 clone --use-client-spec --dest="$git" //depot
 '
 
-test_expect_success 'unsupported view wildcard *' '
+test_expect_success 'view wildcard *' '
        client_view "//depot/*/bar/... //client/*/bar/..." &&
        test_when_finished cleanup_git &&
-       test_must_fail git p4 clone --use-client-spec --dest="$git" //depot
+       git p4 clone --use-client-spec --dest="$git" //depot
 '
 
-test_expect_success 'wildcard ... only supported at end of spec 1' '
+test_expect_success 'wildcard ... in the middle' '
        client_view "//depot/.../file11 //client/.../file11" &&
        test_when_finished cleanup_git &&
-       test_must_fail git p4 clone --use-client-spec --dest="$git" //depot
+       git p4 clone --use-client-spec --dest="$git" //depot
 '
 
-test_expect_success 'wildcard ... only supported at end of spec 2' '
+test_expect_success 'wildcard ... in the middle and at the end' '
        client_view "//depot/.../a/... //client/.../a/..." &&
        test_when_finished cleanup_git &&
-       test_must_fail git p4 clone --use-client-spec --dest="$git" //depot
+       git p4 clone --use-client-spec --dest="$git" //depot
 '
 
 test_expect_success 'basic map' '
@@ -213,7 +196,7 @@ test_expect_success 'exclusion single file' '
 
 test_expect_success 'overlay wildcard' '
        client_view "//depot/dir1/... //client/cli/..." \
-                   "+//depot/dir2/... //client/cli/...\n" &&
+                   "+//depot/dir2/... //client/cli/..." &&
        files="cli/file11 cli/file12 cli/file21 cli/file22" &&
        client_verify $files &&
        test_when_finished cleanup_git &&
@@ -349,7 +332,8 @@ test_expect_success 'subdir clone, submit copy' '
        ) &&
        (
                cd "$cli" &&
-               test_path_is_file dir1/file11a
+               test_path_is_file dir1/file11a &&
+               ! is_cli_file_writeable dir1/file11a
        )
 '
 
@@ -368,14 +352,53 @@ test_expect_success 'subdir clone, submit rename' '
        (
                cd "$cli" &&
                test_path_is_missing dir1/file13 &&
-               test_path_is_file dir1/file13a
+               test_path_is_file dir1/file13a &&
+               ! is_cli_file_writeable dir1/file13a
+       )
+'
+
+# see t9800 for the non-client-spec case, and the rest of the wildcard tests
+test_expect_success 'wildcard files submit back to p4, client-spec case' '
+       client_view "//depot/... //client/..." &&
+       test_when_finished cleanup_git &&
+       git p4 clone --use-client-spec --dest="$git" //depot/dir1 &&
+       (
+               cd "$git" &&
+               echo git-wild-hash >dir1/git-wild#hash &&
+               if test_have_prereq !MINGW,!CYGWIN
+               then
+                       echo git-wild-star >dir1/git-wild\*star
+               fi &&
+               echo git-wild-at >dir1/git-wild@at &&
+               echo git-wild-percent >dir1/git-wild%percent &&
+               git add dir1/git-wild* &&
+               git commit -m "add some wildcard filenames" &&
+               git config git-p4.skipSubmitEditCheck true &&
+               git p4 submit
+       ) &&
+       (
+               cd "$cli" &&
+               test_path_is_file dir1/git-wild#hash &&
+               if test_have_prereq !MINGW,!CYGWIN
+               then
+                       test_path_is_file dir1/git-wild\*star
+               fi &&
+               test_path_is_file dir1/git-wild@at &&
+               test_path_is_file dir1/git-wild%percent
+       ) &&
+       (
+               # delete these carefully, cannot just do "p4 delete"
+               # on files with wildcards; but git-p4 knows how
+               cd "$git" &&
+               git rm dir1/git-wild* &&
+               git commit -m "clean up the wildcards" &&
+               git p4 submit
        )
 '
 
 test_expect_success 'reinit depot' '
        (
                cd "$cli" &&
-               p4 sync -f &&
                rm files &&
                p4 delete */* &&
                p4 submit -d "delete all files" &&