]>
Commit | Line | Data |
---|---|---|
d6a31e08 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='check output directory names used by git-clone' | |
e2efbd23 ÆAB |
4 | |
5 | TEST_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 | |
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" && | |
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 | |
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 | |
db2e2204 | 54 | test_clone_dir host:foo/.git foo.git bare |
d6a31e08 JK |
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 | |
db2e2204 | 62 | test_clone_dir ssh://host/foo/.git foo.git bare |
d6a31e08 JK |
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 | |
db2e2204 JK |
68 | test_clone_dir ssh://host/foo.git/ foo |
69 | test_clone_dir ssh://host/foo.git/// foo | |
d6a31e08 JK |
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 | |
db2e2204 | 75 | test_clone_dir host:foo.git/ foo |
d6a31e08 | 76 | test_clone_dir host:foo/.git/ foo |
db2e2204 | 77 | test_clone_dir host:foo.git/// foo |
d6a31e08 JK |
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 | |
92722efe | 83 | test_clone_dir ssh://host:1234/ host |
e8959867 | 84 | test_clone_dir ssh://user@host/ host |
92722efe | 85 | test_clone_dir host:/ host |
d6a31e08 JK |
86 | |
87 | # auth materials should be redacted | |
e8959867 | 88 | test_clone_dir ssh://user:password@host/ host |
92722efe PS |
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 | |
d6a31e08 JK |
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 |