Merge branch 'jk/fail-null-clone' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 16 Mar 2011 23:47:26 +0000 (16:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Mar 2011 23:47:26 +0000 (16:47 -0700)
* jk/fail-null-clone:
clone: die when trying to clone missing local path

builtin/clone.c
t/t5701-clone-local.sh
index 60d9a64280b0318b1248b229d2ff99b27eb0e5c6..2ee1fa984620de4fad79ce94d4f993f5e83a053d 100644 (file)
@@ -413,7 +413,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (path)
                repo = xstrdup(make_nonrelative_path(repo_name));
        else if (!strchr(repo_name, ':'))
-               repo = xstrdup(make_absolute_path(repo_name));
+               die("repository '%s' does not exist", repo_name);
        else
                repo = repo_name;
        is_local = path && !is_bundle;
index 0f4d487be34d22820bcc63619e6e85b96f18c609..6972258b27f6039e05f6bd2129f9c18ca45404d4 100755 (executable)
@@ -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