French translation: copy -> copie.
[git/dscho.git] / t / t5701-clone-local.sh
blob7ff6e0e16cbeb014c1ea551392a63beca2dbc386
1 #!/bin/sh
3 test_description='test local clone'
4 . ./test-lib.sh
6 repo_is_hardlinked() {
7 find "$1/objects" -type f -links 1 >output &&
8 test_line_count = 0 output
11 test_expect_success 'preparing origin repository' '
12 : >file && git add . && git commit -m1 &&
13 git clone --bare . a.git &&
14 git clone --bare . x &&
15 test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
16 test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true &&
17 git bundle create b1.bundle --all &&
18 git bundle create b2.bundle master &&
19 mkdir dir &&
20 cp b1.bundle dir/b3 &&
21 cp b1.bundle b4
24 test_expect_success 'local clone without .git suffix' '
25 git clone -l -s a b &&
26 (cd b &&
27 test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false &&
28 git fetch)
31 test_expect_success 'local clone with .git suffix' '
32 git clone -l -s a.git c &&
33 (cd c && git fetch)
36 test_expect_success 'local clone from x' '
37 git clone -l -s x y &&
38 (cd y && git fetch)
41 test_expect_success 'local clone from x.git that does not exist' '
42 test_must_fail git clone -l -s x.git z
45 test_expect_success 'With -no-hardlinks, local will make a copy' '
46 git clone --bare --no-hardlinks x w &&
47 ! repo_is_hardlinked w
50 test_expect_success 'Even without -l, local will make a hardlink' '
51 rm -fr w &&
52 git clone -l --bare x w &&
53 repo_is_hardlinked w
56 test_expect_success 'local clone of repo with nonexistent ref in HEAD' '
57 echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
58 git clone a d &&
59 (cd d &&
60 git fetch &&
61 test ! -e .git/refs/remotes/origin/HEAD)
64 test_expect_success 'bundle clone without .bundle suffix' '
65 git clone dir/b3 &&
66 (cd b3 && git fetch)
69 test_expect_success 'bundle clone with .bundle suffix' '
70 git clone b1.bundle &&
71 (cd b1 && git fetch)
74 test_expect_success 'bundle clone from b4' '
75 git clone b4 bdl &&
76 (cd bdl && git fetch)
79 test_expect_success 'bundle clone from b4.bundle that does not exist' '
80 test_must_fail git clone b4.bundle bb
83 test_expect_success 'bundle clone with nonexistent HEAD' '
84 git clone b2.bundle b2 &&
85 (cd b2 &&
86 git fetch &&
87 test_must_fail git rev-parse --verify refs/heads/master)
90 test_expect_success 'clone empty repository' '
91 mkdir empty &&
92 (cd empty &&
93 git init &&
94 git config receive.denyCurrentBranch warn) &&
95 git clone empty empty-clone &&
96 test_tick &&
97 (cd empty-clone
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)
107 test_expect_success 'clone empty repository, and then push should not segfault.' '
108 rm -fr empty/ empty-clone/ &&
109 mkdir empty &&
110 (cd empty && git init) &&
111 git clone empty empty-clone &&
112 (cd empty-clone &&
113 test_must_fail git push)
116 test_expect_success 'cloning non-existent directory fails' '
117 rm -rf does-not-exist &&
118 test_must_fail git clone does-not-exist
121 test_expect_success 'cloning non-git directory fails' '
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
127 test_expect_success 'cloning file:// does not hardlink' '
128 git clone --bare file://"$(pwd)"/a non-local &&
129 ! repo_is_hardlinked non-local
132 test_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
137 test_done