]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5603-clone-dirname.sh
The third batch
[thirdparty/git.git] / t / t5603-clone-dirname.sh
1 #!/bin/sh
2
3 test_description='check output directory names used by git-clone'
4
5 TEST_PASSES_SANITIZE_LEAK=true
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
11 test_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" &&
16 GIT_SSH_VARIANT=ssh &&
17 export GIT_SSH &&
18 export GIT_SSH_VARIANT &&
19 export TRASH_DIRECTORY
20 '
21
22 # make sure that cloning $1 results in local directory $2
23 test_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
49 test_clone_dir host:foo foo
50 test_clone_dir host:foo foo.git bare
51 test_clone_dir host:foo.git foo
52 test_clone_dir host:foo.git foo.git bare
53 test_clone_dir host:foo/.git foo
54 test_clone_dir host:foo/.git foo.git bare
55
56 # similar, but using ssh URL rather than host:path syntax
57 test_clone_dir ssh://host/foo foo
58 test_clone_dir ssh://host/foo foo.git bare
59 test_clone_dir ssh://host/foo.git foo
60 test_clone_dir ssh://host/foo.git foo.git bare
61 test_clone_dir ssh://host/foo/.git foo
62 test_clone_dir ssh://host/foo/.git foo.git bare
63
64 # we should remove trailing slashes and .git suffixes
65 test_clone_dir ssh://host/foo/ foo
66 test_clone_dir ssh://host/foo/// foo
67 test_clone_dir ssh://host/foo/.git/ foo
68 test_clone_dir ssh://host/foo.git/ foo
69 test_clone_dir ssh://host/foo.git/// foo
70 test_clone_dir ssh://host/foo///.git/ foo
71 test_clone_dir ssh://host/foo/.git/// foo
72
73 test_clone_dir host:foo/ foo
74 test_clone_dir host:foo/// foo
75 test_clone_dir host:foo.git/ foo
76 test_clone_dir host:foo/.git/ foo
77 test_clone_dir host:foo.git/// foo
78 test_clone_dir host:foo///.git/ foo
79 test_clone_dir host:foo/.git/// foo
80
81 # omitting the path should default to the hostname
82 test_clone_dir ssh://host/ host
83 test_clone_dir ssh://host:1234/ host
84 test_clone_dir ssh://user@host/ host
85 test_clone_dir host:/ host
86
87 # auth materials should be redacted
88 test_clone_dir ssh://user:password@host/ host
89 test_clone_dir ssh://user:password@host:1234/ host
90 test_clone_dir ssh://user:passw@rd@host:1234/ host
91 test_clone_dir user@host:/ host
92 test_clone_dir user:password@host:/ host
93 test_clone_dir user:passw@rd@host:/ host
94
95 # auth-like material should not be dropped
96 test_clone_dir ssh://host/foo@bar foo@bar
97 test_clone_dir ssh://host/foo@bar.git foo@bar
98 test_clone_dir ssh://user:password@host/foo@bar foo@bar
99 test_clone_dir ssh://user:passw@rd@host/foo@bar.git foo@bar
100
101 test_clone_dir host:/foo@bar foo@bar
102 test_clone_dir host:/foo@bar.git foo@bar
103 test_clone_dir user:password@host:/foo@bar foo@bar
104 test_clone_dir user:passw@rd@host:/foo@bar.git foo@bar
105
106 # trailing port-like numbers should not be stripped for paths
107 test_clone_dir ssh://user:password@host/test:1234 1234
108 test_clone_dir ssh://user:password@host/test:1234.git 1234
109
110 test_done