Merge branch 'master' of github.com:Softcatala/git-po
[git/debian.git] / t / t5580-unc-paths.sh
blobcd803ae8bf1abd47e691004e34149a059b8d611b
1 #!/bin/sh
3 test_description='various Windows-only path tests'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 if test_have_prereq CYGWIN
10 then
11 alias winpwd='cygpath -aw .'
12 elif test_have_prereq MINGW
13 then
14 alias winpwd=pwd
15 else
16 skip_all='skipping Windows-only path tests'
17 test_done
20 UNCPATH="$(winpwd)"
21 case "$UNCPATH" in
22 [A-Z]:*)
23 # Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git
24 # (we use forward slashes here because MSYS2 and Git accept them, and
25 # they are easier on the eyes)
26 UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}"
27 test -d "$UNCPATH" || {
28 skip_all='could not access administrative share; skipping'
29 test_done
33 skip_all='skipping UNC path tests, cannot determine current path as UNC'
34 test_done
36 esac
38 test_expect_success setup '
39 test_commit initial
42 test_expect_success clone '
43 git clone "file://$UNCPATH" clone
46 test_expect_success 'clone without file://' '
47 git clone "$UNCPATH" clone-without-file
50 test_expect_success 'clone with backslashed path' '
51 BACKSLASHED="$(echo "$UNCPATH" | tr / \\\\)" &&
52 git clone "$BACKSLASHED" backslashed
55 test_expect_success fetch '
56 git init to-fetch &&
58 cd to-fetch &&
59 git fetch "$UNCPATH" main
63 test_expect_success push '
65 cd clone &&
66 git checkout -b to-push &&
67 test_commit to-push &&
68 git push origin HEAD
69 ) &&
70 rev="$(git -C clone rev-parse --verify refs/heads/to-push)" &&
71 test "$rev" = "$(git rev-parse --verify refs/heads/to-push)"
74 test_expect_success MINGW 'remote nick cannot contain backslashes' '
75 BACKSLASHED="$(winpwd | tr / \\\\)" &&
76 git ls-remote "$BACKSLASHED" 2>err &&
77 test_i18ngrep ! "unable to access" err
80 test_expect_success 'unc alternates' '
81 tree="$(git rev-parse HEAD:)" &&
82 mkdir test-unc-alternate &&
84 cd test-unc-alternate &&
85 git init &&
86 test_must_fail git show $tree &&
87 echo "$UNCPATH/.git/objects" >.git/objects/info/alternates &&
88 git show $tree
92 test_done