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