]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5580-unc-paths.sh
Merge branch 'mh/credential-oauth-refresh-token-with-wincred'
[thirdparty/git.git] / t / t5580-unc-paths.sh
1 #!/bin/sh
2
3 test_description='various Windows-only path tests'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
9
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
19 fi
20
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
31 }
32 ;;
33 *)
34 skip_all='skipping UNC path tests, cannot determine current path as UNC'
35 test_done
36 ;;
37 esac
38
39 test_expect_success setup '
40 test_commit initial
41 '
42
43 test_expect_success clone '
44 git clone "file://$UNCPATH" clone
45 '
46
47 test_expect_success 'clone without file://' '
48 git clone "$UNCPATH" clone-without-file
49 '
50
51 test_expect_success 'clone with backslashed path' '
52 BACKSLASHED="$(echo "$UNCPATH" | tr / \\\\)" &&
53 git clone "$BACKSLASHED" backslashed
54 '
55
56 test_expect_success fetch '
57 git init to-fetch &&
58 (
59 cd to-fetch &&
60 git fetch "$UNCPATH" main
61 )
62 '
63
64 test_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
75 test_expect_success MINGW 'remote nick cannot contain backslashes' '
76 BACKSLASHED="$(winpwd | tr / \\\\)" &&
77 git ls-remote "$BACKSLASHED" 2>err &&
78 test_grep ! "unable to access" err
79 '
80
81 test_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
93 test_done