]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/lib-git-p4.sh
git p4 test: translate windows paths for cygwin
[thirdparty/git.git] / t / lib-git-p4.sh
index 185f6f1a8d882e3f6d795e09bdb2d41ee7ca4670..d5596ded6cc2a9b68f073d070ca3714349886738 100644 (file)
@@ -8,7 +8,8 @@ TEST_NO_CREATE_REPO=NoThanks
 
 . ./test-lib.sh
 
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
        skip_all='skipping git p4 tests; python not available'
        test_done
 fi
@@ -17,6 +18,24 @@ fi
        test_done
 }
 
+# On cygwin, the NT version of Perforce can be used.  When giving
+# it paths, either on the command-line or in client specifications,
+# be sure to use the native windows form.
+#
+# Older versions of perforce were available compiled natively for
+# cygwin.  Those do not accept native windows paths, so make sure
+# not to convert for them.
+native_path() {
+       path="$1" &&
+       if test_have_prereq CYGWIN && ! p4 -V | grep -q CYGWIN
+       then
+               path=$(cygpath --windows "$path")
+       else
+               path=$(test-path-utils real_path "$path")
+       fi &&
+       echo "$path"
+}
+
 # Try to pick a unique port: guess a large number, then hope
 # no more than one of each test is running.
 #
@@ -32,7 +51,7 @@ P4EDITOR=:
 export P4PORT P4CLIENT P4EDITOR
 
 db="$TRASH_DIRECTORY/db"
-cli=$(test-path-utils real_path "$TRASH_DIRECTORY/cli")
+cli="$TRASH_DIRECTORY/cli"
 git="$TRASH_DIRECTORY/git"
 pidfile="$TRASH_DIRECTORY/p4d.pid"
 
@@ -122,6 +141,7 @@ client_view() {
                Client: $P4CLIENT
                Description: $P4CLIENT
                Root: $cli
+               AltRoots: $(native_path "$cli")
                View:
                EOF
                printf "\t%s\n" "$@"