summaryrefslogtreecommitdiff
path: root/t/t5701-clone-local.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-02-17 23:01:52 -0500
committerJunio C Hamano <gitster@pobox.com>2011-02-18 07:05:54 -0800
commita9026187923643235d4f9b876ff5f4c0ebe5c9ae (patch)
tree6a61ec682b5ce41edec0f9188c5319263b8cd410 /t/t5701-clone-local.sh
parent7ed863a85a6ce2c4ac4476848310b8f917ab41f9 (diff)
downloadgit-a9026187923643235d4f9b876ff5f4c0ebe5c9ae.tar.gz
clone: die when trying to clone missing local path
Since 86ac751 (Allow cloning an empty repository, 2009-01-23), doing: git clone does-not-exist has created does-not-exist as an empty repository. This was an unintentional side effect of 86ac751. Even weirder, doing: git clone does-not-exist new-dir _does_ fail, making this "feature" (if you want to consider it such) broken. Let's detect this situation and explicitly die. It's almost certainly not what the user intended. This patch also adds two tests. One for the missing path case, and one to confirm that a similar case, cloning a non-repository directory, fails. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5701-clone-local.sh')
-rwxr-xr-xt/t5701-clone-local.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index 0f4d487be3..6972258b27 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -144,4 +144,17 @@ test_expect_success 'clone empty repository, and then push should not segfault.'
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