ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
[gitweb.git] / t / t9806-git-p4-options.sh
index 4f077eeca86946aa897f15e9f1729f9d0588cfb9..1ab76c4246f215cfc0082bdbfd090e1622362140 100755 (executable)
@@ -214,40 +214,33 @@ test_expect_success 'clone --use-client-spec' '
                exec >/dev/null &&
                test_must_fail git p4 clone --dest="$git" --use-client-spec
        ) &&
-       cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") &&
+       # build a different client
+       cli2="$TRASH_DIRECTORY/cli2" &&
        mkdir -p "$cli2" &&
        test_when_finished "rmdir \"$cli2\"" &&
-       (
-               cd "$cli2" &&
-               p4 client -i <<-EOF
-               Client: client2
-               Description: client2
-               Root: $cli2
-               View: //depot/sub/... //client2/bus/...
-               EOF
-       ) &&
        test_when_finished cleanup_git &&
        (
+               # group P4CLIENT and cli changes in a sub-shell
                P4CLIENT=client2 &&
-               git p4 clone --dest="$git" --use-client-spec //depot/...
-       ) &&
-       (
-               cd "$git" &&
-               test_path_is_file bus/dir/f4 &&
-               test_path_is_missing file1
-       ) &&
-       cleanup_git &&
-
-       # same thing again, this time with variable instead of option
-       (
-               cd "$git" &&
-               git init &&
-               git config git-p4.useClientSpec true &&
-               P4CLIENT=client2 &&
-               git p4 sync //depot/... &&
-               git checkout -b master p4/master &&
-               test_path_is_file bus/dir/f4 &&
-               test_path_is_missing file1
+               cli="$cli2" &&
+               client_view "//depot/sub/... //client2/bus/..." &&
+               git p4 clone --dest="$git" --use-client-spec //depot/... &&
+               (
+                       cd "$git" &&
+                       test_path_is_file bus/dir/f4 &&
+                       test_path_is_missing file1
+               ) &&
+               cleanup_git &&
+               # same thing again, this time with variable instead of option
+               (
+                       cd "$git" &&
+                       git init &&
+                       git config git-p4.useClientSpec true &&
+                       git p4 sync //depot/... &&
+                       git checkout -b master p4/master &&
+                       test_path_is_file bus/dir/f4 &&
+                       test_path_is_missing file1
+               )
        )
 '
 
@@ -276,6 +269,38 @@ test_expect_success 'submit works with two branches' '
        )
 '
 
+test_expect_success 'use --git-dir option and GIT_DIR' '
+       test_when_finished cleanup_git &&
+       git p4 clone //depot --destination="$git" &&
+       (
+               cd "$git" &&
+               git config git-p4.skipSubmitEdit true &&
+               test_commit first-change &&
+               git p4 submit --git-dir "$git"
+       ) &&
+       (
+               cd "$cli" &&
+               p4 sync &&
+               test_path_is_file first-change.t &&
+               echo "cli_file" >cli_file.t &&
+               p4 add cli_file.t &&
+               p4 submit -d "cli change"
+       ) &&
+       (git --git-dir "$git" p4 sync) &&
+       (cd "$git" && git checkout -q p4/master) &&
+       test_path_is_file "$git"/cli_file.t &&
+       (
+               cd "$cli" &&
+               echo "cli_file2" >cli_file2.t &&
+               p4 add cli_file2.t  &&
+               p4 submit -d "cli change2"
+       ) &&
+       (GIT_DIR="$git" git p4 sync) &&
+       (cd "$git" && git checkout -q p4/master) &&
+       test_path_is_file "$git"/cli_file2.t
+'
+
+
 test_expect_success 'kill p4d' '
        kill_p4d
 '