Code

Git 1.7.8.1
[git.git] / t / t5701-clone-local.sh
index 8dfaaa456e115e85e36c438bb998d8053534104e..6972258b27f6039e05f6bd2129f9c18ca45404d4 100755 (executable)
@@ -10,11 +10,11 @@ test_expect_success 'preparing origin repository' '
        git clone --bare . a.git &&
        git clone --bare . x &&
        test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
-       test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true
-       git bundle create b1.bundle --all HEAD &&
-       git bundle create b2.bundle --all &&
+       test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true &&
+       git bundle create b1.bundle --all &&
+       git bundle create b2.bundle master &&
        mkdir dir &&
-       cp b1.bundle dir/b3
+       cp b1.bundle dir/b3 &&
        cp b1.bundle b4
 '
 
@@ -112,8 +112,49 @@ test_expect_success 'bundle clone with nonexistent HEAD' '
        cd "$D" &&
        git clone b2.bundle b2 &&
        cd b2 &&
-       git fetch
+       git fetch &&
        test ! -e .git/refs/heads/master
 '
 
+test_expect_success 'clone empty repository' '
+       cd "$D" &&
+       mkdir empty &&
+       (cd empty &&
+        git init &&
+        git config receive.denyCurrentBranch warn) &&
+       git clone empty empty-clone &&
+       test_tick &&
+       (cd empty-clone
+        echo "content" >> foo &&
+        git add foo &&
+        git commit -m "Initial commit" &&
+        git push origin master &&
+        expected=$(git rev-parse master) &&
+        actual=$(git --git-dir=../empty/.git rev-parse master) &&
+        test $actual = $expected)
+'
+
+test_expect_success 'clone empty repository, and then push should not segfault.' '
+       cd "$D" &&
+       rm -fr empty/ empty-clone/ &&
+       mkdir empty &&
+       (cd empty && git init) &&
+       git clone empty empty-clone &&
+       (cd empty-clone &&
+       test_must_fail git push)
+'
+
+test_expect_success 'cloning non-existent directory fails' '
+       cd "$D" &&
+       rm -rf does-not-exist &&
+       test_must_fail git clone does-not-exist
+'
+
+test_expect_success 'cloning non-git directory fails' '
+       cd "$D" &&
+       rm -rf not-a-git-repo not-a-git-repo-clone &&
+       mkdir not-a-git-repo &&
+       test_must_fail git clone not-a-git-repo not-a-git-repo-clone
+'
+
 test_done