]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5580-unc-paths.sh
The third batch
[thirdparty/git.git] / t / t5580-unc-paths.sh
CommitLineData
16615f0f
JS
1#!/bin/sh
2
13b57da8 3test_description='various Windows-only path tests'
028cb644 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
288a4806 7TEST_PASSES_SANITIZE_LEAK=true
16615f0f
JS
8. ./test-lib.sh
9
f21d60b4
AD
10if test_have_prereq CYGWIN
11then
12 alias winpwd='cygpath -aw .'
13elif test_have_prereq MINGW
14then
15 alias winpwd=pwd
16else
13b57da8 17 skip_all='skipping Windows-only path tests'
16615f0f
JS
18 test_done
19fi
20
f21d60b4 21UNCPATH="$(winpwd)"
16615f0f
JS
22case "$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
31 }
32 ;;
33*)
34 skip_all='skipping UNC path tests, cannot determine current path as UNC'
35 test_done
36 ;;
37esac
38
39test_expect_success setup '
40 test_commit initial
41'
42
43test_expect_success clone '
44 git clone "file://$UNCPATH" clone
45'
46
bfe2bbb4
JS
47test_expect_success 'clone without file://' '
48 git clone "$UNCPATH" clone-without-file
49'
50
9e9da23c 51test_expect_success 'clone with backslashed path' '
5440df44
JS
52 BACKSLASHED="$(echo "$UNCPATH" | tr / \\\\)" &&
53 git clone "$BACKSLASHED" backslashed
54'
55
bfe2bbb4
JS
56test_expect_success fetch '
57 git init to-fetch &&
58 (
59 cd to-fetch &&
028cb644 60 git fetch "$UNCPATH" main
bfe2bbb4
JS
61 )
62'
63
16615f0f
JS
64test_expect_success push '
65 (
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)"
73'
74
f21d60b4
AD
75test_expect_success MINGW 'remote nick cannot contain backslashes' '
76 BACKSLASHED="$(winpwd | tr / \\\\)" &&
01ed17dc 77 git ls-remote "$BACKSLASHED" 2>err &&
6789275d 78 test_grep ! "unable to access" err
13b57da8
JS
79'
80
397a46db
JS
81test_expect_success 'unc alternates' '
82 tree="$(git rev-parse HEAD:)" &&
83 mkdir test-unc-alternate &&
84 (
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
90 )
91'
92
16615f0f 93test_done