]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5605-clone-local.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t5605-clone-local.sh
CommitLineData
defe13a2
AR
1#!/bin/sh
2
3test_description='test local clone'
4. ./test-lib.sh
5
f27e7654
JK
6repo_is_hardlinked() {
7 find "$1/objects" -type f -links 1 >output &&
8 test_line_count = 0 output
9}
defe13a2
AR
10
11test_expect_success 'preparing origin repository' '
12 : >file && git add . && git commit -m1 &&
13 git clone --bare . a.git &&
312efe9b 14 git clone --bare . x &&
3cc6a6f0
JK
15 test "$(cd a.git && git config --bool core.bare)" = true &&
16 test "$(cd x && git config --bool core.bare)" = true &&
b2a6d1c6 17 git bundle create b1.bundle --all &&
f0298cf1 18 git bundle create b2.bundle master &&
c6fef0bb 19 mkdir dir &&
2dec68cf 20 cp b1.bundle dir/b3 &&
c6fef0bb 21 cp b1.bundle b4
defe13a2
AR
22'
23
24test_expect_success 'local clone without .git suffix' '
defe13a2 25 git clone -l -s a b &&
f27e7654 26 (cd b &&
3cc6a6f0 27 test "$(git config --bool core.bare)" = false &&
f27e7654 28 git fetch)
defe13a2
AR
29'
30
31test_expect_success 'local clone with .git suffix' '
defe13a2 32 git clone -l -s a.git c &&
f27e7654 33 (cd c && git fetch)
defe13a2
AR
34'
35
36test_expect_success 'local clone from x' '
defe13a2 37 git clone -l -s x y &&
f27e7654 38 (cd y && git fetch)
defe13a2
AR
39'
40
41test_expect_success 'local clone from x.git that does not exist' '
f27e7654 42 test_must_fail git clone -l -s x.git z
defe13a2
AR
43'
44
3d5c418f 45test_expect_success 'With -no-hardlinks, local will make a copy' '
3d5c418f 46 git clone --bare --no-hardlinks x w &&
f27e7654 47 ! repo_is_hardlinked w
3d5c418f
JH
48'
49
50test_expect_success 'Even without -l, local will make a hardlink' '
3d5c418f
JH
51 rm -fr w &&
52 git clone -l --bare x w &&
f27e7654 53 repo_is_hardlinked w
3d5c418f
JH
54'
55
5274ba69 56test_expect_success 'local clone of repo with nonexistent ref in HEAD' '
5274ba69
GP
57 echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
58 git clone a d &&
f27e7654 59 (cd d &&
5274ba69 60 git fetch &&
f27e7654
JK
61 test ! -e .git/refs/remotes/origin/HEAD)
62'
5274ba69 63
c6fef0bb 64test_expect_success 'bundle clone without .bundle suffix' '
c6fef0bb 65 git clone dir/b3 &&
f27e7654 66 (cd b3 && git fetch)
c6fef0bb
SB
67'
68
69test_expect_success 'bundle clone with .bundle suffix' '
c6fef0bb 70 git clone b1.bundle &&
f27e7654 71 (cd b1 && git fetch)
c6fef0bb
SB
72'
73
74test_expect_success 'bundle clone from b4' '
c6fef0bb 75 git clone b4 bdl &&
f27e7654 76 (cd bdl && git fetch)
c6fef0bb
SB
77'
78
79test_expect_success 'bundle clone from b4.bundle that does not exist' '
f27e7654 80 test_must_fail git clone b4.bundle bb
c6fef0bb
SB
81'
82
83test_expect_success 'bundle clone with nonexistent HEAD' '
c6fef0bb 84 git clone b2.bundle b2 &&
f27e7654 85 (cd b2 &&
2dec68cf 86 git fetch &&
f27e7654 87 test_must_fail git rev-parse --verify refs/heads/master)
c6fef0bb
SB
88'
89
86ac7518 90test_expect_success 'clone empty repository' '
86ac7518 91 mkdir empty &&
acd2a45b
JH
92 (cd empty &&
93 git init &&
94 git config receive.denyCurrentBranch warn) &&
86ac7518
SR
95 git clone empty empty-clone &&
96 test_tick &&
51b85471 97 (cd empty-clone &&
86ac7518
SR
98 echo "content" >> foo &&
99 git add foo &&
100 git commit -m "Initial commit" &&
101 git push origin master &&
102 expected=$(git rev-parse master) &&
103 actual=$(git --git-dir=../empty/.git rev-parse master) &&
104 test $actual = $expected)
105'
106
a162e78d 107test_expect_success 'clone empty repository, and then push should not segfault.' '
a162e78d
MM
108 rm -fr empty/ empty-clone/ &&
109 mkdir empty &&
110 (cd empty && git init) &&
111 git clone empty empty-clone &&
b9d622e7
JS
112 (cd empty-clone &&
113 test_must_fail git push)
a162e78d
MM
114'
115
a9026187 116test_expect_success 'cloning non-existent directory fails' '
a9026187
JK
117 rm -rf does-not-exist &&
118 test_must_fail git clone does-not-exist
119'
120
121test_expect_success 'cloning non-git directory fails' '
a9026187
JK
122 rm -rf not-a-git-repo not-a-git-repo-clone &&
123 mkdir not-a-git-repo &&
124 test_must_fail git clone not-a-git-repo not-a-git-repo-clone
125'
126
189260b1
JK
127test_expect_success 'cloning file:// does not hardlink' '
128 git clone --bare file://"$(pwd)"/a non-local &&
129 ! repo_is_hardlinked non-local
130'
131
132test_expect_success 'cloning a local path with --no-local does not hardlink' '
133 git clone --bare --no-local a force-nonlocal &&
134 ! repo_is_hardlinked force-nonlocal
135'
136
643f918d
JK
137test_expect_success 'cloning locally respects "-u" for fetching refs' '
138 test_must_fail git clone --bare -u false a should_not_work.git
139'
140
defe13a2 141test_done