Merge branch 'l10n/zh_TW/220113' of github.com:l10n-tw/git-po
[alt-git.git] / t / t5580-unc-paths.sh
blobcd7604fff93a55ff9bb9e4bcae905c4386f0374a
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_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 if test_have_prereq CYGWIN
11 then
12 alias winpwd='cygpath -aw .'
13 elif test_have_prereq MINGW
14 then
15 alias winpwd=pwd
16 else
17 skip_all='skipping Windows-only path tests'
18 test_done
21 UNCPATH="$(winpwd)"
22 case "$UNCPATH" in
23 [A-Z]:*)
24 # Use administrative share e.g. \\localhost\C$\git-sdk-64\usr\src\git
25 # (we use forward slashes here because MSYS2 and Git accept them, and
26 # they are easier on the eyes)
27 UNCPATH="//localhost/${UNCPATH%%:*}\$/${UNCPATH#?:}"
28 test -d "$UNCPATH" || {
29 skip_all='could not access administrative share; skipping'
30 test_done
34 skip_all='skipping UNC path tests, cannot determine current path as UNC'
35 test_done
37 esac
39 test_expect_success setup '
40 test_commit initial
43 test_expect_success clone '
44 git clone "file://$UNCPATH" clone
47 test_expect_success 'clone without file://' '
48 git clone "$UNCPATH" clone-without-file
51 test_expect_success 'clone with backslashed path' '
52 BACKSLASHED="$(echo "$UNCPATH" | tr / \\\\)" &&
53 git clone "$BACKSLASHED" backslashed
56 test_expect_success fetch '
57 git init to-fetch &&
59 cd to-fetch &&
60 git fetch "$UNCPATH" main
64 test_expect_success push '
66 cd clone &&
67 git checkout -b to-push &&
68 test_commit to-push &&
69 git push origin HEAD
70 ) &&
71 rev="$(git -C clone rev-parse --verify refs/heads/to-push)" &&
72 test "$rev" = "$(git rev-parse --verify refs/heads/to-push)"
75 test_expect_success MINGW 'remote nick cannot contain backslashes' '
76 BACKSLASHED="$(winpwd | tr / \\\\)" &&
77 git ls-remote "$BACKSLASHED" 2>err &&
78 test_i18ngrep ! "unable to access" err
81 test_expect_success 'unc alternates' '
82 tree="$(git rev-parse HEAD:)" &&
83 mkdir test-unc-alternate &&
85 cd test-unc-alternate &&
86 git init &&
87 test_must_fail git show $tree &&
88 echo "$UNCPATH/.git/objects" >.git/objects/info/alternates &&
89 git show $tree
93 test_done