7 test_expect_success setup
'
10 test_create_repo src &&
20 test_expect_success
'clone with excess parameters (1)' '
23 test_must_fail git clone -n src dst junk
27 test_expect_success
'clone with excess parameters (2)' '
30 test_must_fail git clone -n "file://$(pwd)/src" dst junk
34 test_expect_success C_LOCALE_OUTPUT
'output from clone' '
36 git clone -n "file://$(pwd)/src" dst >output &&
37 test $(grep Clon output | wc -l) = 1
40 test_expect_success
'clone does not keep pack' '
43 git clone -n "file://$(pwd)/src" dst &&
45 ! (echo dst/.git/objects/pack/pack-* | grep "\.keep")
49 test_expect_success
'clone checks out files' '
57 test_expect_success
'clone respects GIT_WORK_TREE' '
59 GIT_WORK_TREE=worktree git clone src bare &&
60 test -f bare/config &&
65 test_expect_success
'clone creates intermediate directories' '
67 git clone src long/path/to/dst &&
68 test -f long/path/to/dst/file
72 test_expect_success
'clone creates intermediate directories for bare repo' '
74 git clone --bare src long/path/to/bare/dst &&
75 test -f long/path/to/bare/dst/config
79 test_expect_success
'clone --mirror' '
81 git clone --mirror src mirror &&
82 test -f mirror/HEAD &&
83 test ! -f mirror/file &&
84 FETCH="$(cd mirror && git config remote.origin.fetch)" &&
85 test "+refs/*:refs/*" = "$FETCH" &&
86 MIRROR="$(cd mirror && git config --bool remote.origin.mirror)" &&
91 test_expect_success
'clone --bare names the local repository <name>.git' '
93 git clone --bare src &&
98 test_expect_success
'clone --mirror does not repeat tags' '
101 git tag some-tag HEAD) &&
102 git clone --mirror src mirror2 &&
104 git show-ref 2> clone.err > clone.out) &&
105 test_must_fail grep Duplicate mirror2/clone.err &&
106 grep some-tag mirror2/clone.out
110 test_expect_success
'clone to destination with trailing /' '
112 git clone src target-1/ &&
113 T=$( cd target-1 && git rev-parse HEAD ) &&
114 S=$( cd src && git rev-parse HEAD ) &&
119 test_expect_success
'clone to destination with extra trailing /' '
121 git clone src target-2/// &&
122 T=$( cd target-2 && git rev-parse HEAD ) &&
123 S=$( cd src && git rev-parse HEAD ) &&
128 test_expect_success
'clone to an existing empty directory' '
130 git clone src target-3 &&
131 T=$( cd target-3 && git rev-parse HEAD ) &&
132 S=$( cd src && git rev-parse HEAD ) &&
136 test_expect_success
'clone to an existing non-empty directory' '
138 >target-4/Fakefile &&
139 test_must_fail git clone src target-4
142 test_expect_success
'clone to an existing path' '
144 test_must_fail git clone src target-5
147 test_expect_success
'clone a void' '
152 git clone "file://$(pwd)/src-0" target-6 2>err-6 &&
153 ! grep "fatal:" err-6 &&
155 cd src-0 && test_commit A
157 git clone "file://$(pwd)/src-0" target-7 2>err-7 &&
158 ! grep "fatal:" err-7 &&
159 # There is no reason to insist they are bit-for-bit
160 # identical, but this test should suffice for now.
161 test_cmp target-6/.git/config target-7/.git/config
164 test_expect_success
'clone respects global branch.autosetuprebase' '
166 test_config="$HOME/.gitconfig" &&
167 git config -f "$test_config" branch.autosetuprebase remote &&
171 actual="z$(git config branch.master.rebase)" &&
176 test_expect_success
'respect url-encoding of file://' '
178 git clone "file://$PWD/x+y" xy-url-1 &&
179 git clone "file://$PWD/x%2By" xy-url-2
182 test_expect_success
'do not query-string-decode + in URLs' '
185 test_must_fail git clone "file://$PWD/x+y" xy-no-plus
188 test_expect_success
'do not respect url-encoding of non-url path' '
190 test_must_fail git clone x%2By xy-regular &&
191 git clone x+y xy-regular
194 test_expect_success
'clone separate gitdir' '
196 git clone --separate-git-dir realgitdir src dst &&
197 test -d realgitdir/refs
200 test_expect_success
'clone separate gitdir: output' '
201 echo "gitdir: `pwd`/realgitdir" >expected &&
202 test_cmp expected dst/.git
205 test_expect_success
'clone separate gitdir where target already exists' '
207 test_must_fail git clone --separate-git-dir realgitdir src dst