Skip to content

Commit 8209b7f

Browse files
committed
Merge branch 'jk/fail-null-clone' into maint
* jk/fail-null-clone: clone: die when trying to clone missing local path
2 parents 61a6f1f + a902618 commit 8209b7f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
413413
if (path)
414414
repo = xstrdup(make_nonrelative_path(repo_name));
415415
else if (!strchr(repo_name, ':'))
416-
repo = xstrdup(make_absolute_path(repo_name));
416+
die("repository '%s' does not exist", repo_name);
417417
else
418418
repo = repo_name;
419419
is_local = path && !is_bundle;

t/t5701-clone-local.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,17 @@ test_expect_success 'clone empty repository, and then push should not segfault.'
144144
test_must_fail git push)
145145
'
146146

147+
test_expect_success 'cloning non-existent directory fails' '
148+
cd "$D" &&
149+
rm -rf does-not-exist &&
150+
test_must_fail git clone does-not-exist
151+
'
152+
153+
test_expect_success 'cloning non-git directory fails' '
154+
cd "$D" &&
155+
rm -rf not-a-git-repo not-a-git-repo-clone &&
156+
mkdir not-a-git-repo &&
157+
test_must_fail git clone not-a-git-repo not-a-git-repo-clone
158+
'
159+
147160
test_done

0 commit comments

Comments
 (0)