Browse Source

Merge branch 'jk/fail-null-clone'

* jk/fail-null-clone:
  clone: die when trying to clone missing local path
maint
Junio C Hamano 14 years ago
parent
commit
51aca1665b
  1. 2
      builtin/clone.c
  2. 13
      t/t5701-clone-local.sh

2
builtin/clone.c

@ -413,7 +413,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (path) if (path)
repo = xstrdup(make_nonrelative_path(repo_name)); repo = xstrdup(make_nonrelative_path(repo_name));
else if (!strchr(repo_name, ':')) else if (!strchr(repo_name, ':'))
repo = xstrdup(make_absolute_path(repo_name)); die("repository '%s' does not exist", repo_name);
else else
repo = repo_name; repo = repo_name;
is_local = path && !is_bundle; is_local = path && !is_bundle;

13
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_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 test_done

Loading…
Cancel
Save