]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5603-clone-dirname.sh
The second batch
[thirdparty/git.git] / t / t5603-clone-dirname.sh
CommitLineData
d6a31e08
JK
1#!/bin/sh
2
3test_description='check output directory names used by git-clone'
e2efbd23
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
d6a31e08
JK
6. ./test-lib.sh
7
8# we use a fake ssh wrapper that ignores the arguments
9# entirely; we really only care that we get _some_ repo,
10# as the real test is what clone does on the local side
11test_expect_success 'setup ssh wrapper' '
12 write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF &&
13 git upload-pack "$TRASH_DIRECTORY"
14 EOF
15 GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" &&
3fa5e0d0 16 GIT_SSH_VARIANT=ssh &&
d6a31e08 17 export GIT_SSH &&
3fa5e0d0 18 export GIT_SSH_VARIANT &&
d6a31e08
JK
19 export TRASH_DIRECTORY
20'
21
22# make sure that cloning $1 results in local directory $2
23test_clone_dir () {
24 url=$1; shift
25 dir=$1; shift
26 expect=success
27 bare=non-bare
28 clone_opts=
29 for i in "$@"
30 do
31 case "$i" in
32 fail)
33 expect=failure
34 ;;
35 bare)
36 bare=bare
37 clone_opts=--bare
38 ;;
39 esac
40 done
41 test_expect_$expect "clone of $url goes to $dir ($bare)" "
42 rm -rf $dir &&
43 git clone $clone_opts $url &&
44 test_path_is_dir $dir
45 "
46}
47
48# basic syntax with bare and non-bare variants
49test_clone_dir host:foo foo
50test_clone_dir host:foo foo.git bare
51test_clone_dir host:foo.git foo
52test_clone_dir host:foo.git foo.git bare
53test_clone_dir host:foo/.git foo
db2e2204 54test_clone_dir host:foo/.git foo.git bare
d6a31e08
JK
55
56# similar, but using ssh URL rather than host:path syntax
57test_clone_dir ssh://host/foo foo
58test_clone_dir ssh://host/foo foo.git bare
59test_clone_dir ssh://host/foo.git foo
60test_clone_dir ssh://host/foo.git foo.git bare
61test_clone_dir ssh://host/foo/.git foo
db2e2204 62test_clone_dir ssh://host/foo/.git foo.git bare
d6a31e08
JK
63
64# we should remove trailing slashes and .git suffixes
65test_clone_dir ssh://host/foo/ foo
66test_clone_dir ssh://host/foo/// foo
67test_clone_dir ssh://host/foo/.git/ foo
db2e2204
JK
68test_clone_dir ssh://host/foo.git/ foo
69test_clone_dir ssh://host/foo.git/// foo
d6a31e08
JK
70test_clone_dir ssh://host/foo///.git/ foo
71test_clone_dir ssh://host/foo/.git/// foo
72
73test_clone_dir host:foo/ foo
74test_clone_dir host:foo/// foo
db2e2204 75test_clone_dir host:foo.git/ foo
d6a31e08 76test_clone_dir host:foo/.git/ foo
db2e2204 77test_clone_dir host:foo.git/// foo
d6a31e08
JK
78test_clone_dir host:foo///.git/ foo
79test_clone_dir host:foo/.git/// foo
80
81# omitting the path should default to the hostname
82test_clone_dir ssh://host/ host
92722efe 83test_clone_dir ssh://host:1234/ host
e8959867 84test_clone_dir ssh://user@host/ host
92722efe 85test_clone_dir host:/ host
d6a31e08
JK
86
87# auth materials should be redacted
e8959867 88test_clone_dir ssh://user:password@host/ host
92722efe
PS
89test_clone_dir ssh://user:password@host:1234/ host
90test_clone_dir ssh://user:passw@rd@host:1234/ host
91test_clone_dir user@host:/ host
92test_clone_dir user:password@host:/ host
93test_clone_dir user:passw@rd@host:/ host
d6a31e08
JK
94
95# auth-like material should not be dropped
96test_clone_dir ssh://host/foo@bar foo@bar
97test_clone_dir ssh://host/foo@bar.git foo@bar
98test_clone_dir ssh://user:password@host/foo@bar foo@bar
99test_clone_dir ssh://user:passw@rd@host/foo@bar.git foo@bar
100
101test_clone_dir host:/foo@bar foo@bar
102test_clone_dir host:/foo@bar.git foo@bar
103test_clone_dir user:password@host:/foo@bar foo@bar
104test_clone_dir user:passw@rd@host:/foo@bar.git foo@bar
105
106# trailing port-like numbers should not be stripped for paths
107test_clone_dir ssh://user:password@host/test:1234 1234
108test_clone_dir ssh://user:password@host/test:1234.git 1234
109
110test_done