Skip to content

Commit c6babe5

Browse files
committed
Merge branch 'nd/clone-depth-zero'
* nd/clone-depth-zero: clone: warn users --depth is ignored in local clones
2 parents f9c8e7c + 24c61c4 commit c6babe5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

builtin/clone.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static void write_remote_refs(const struct ref *local_refs)
361361

362362
int cmd_clone(int argc, const char **argv, const char *prefix)
363363
{
364-
int is_bundle = 0;
364+
int is_bundle = 0, is_local;
365365
struct stat buf;
366366
const char *repo_name, *repo, *work_tree, *git_dir;
367367
char *path, *dir;
@@ -414,6 +414,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
414414
repo = xstrdup(make_absolute_path(repo_name));
415415
else
416416
repo = repo_name;
417+
is_local = path && !is_bundle;
418+
if (is_local && option_depth)
419+
warning("--depth is ignored in local clones; use file:// instead.");
417420

418421
if (argc == 2)
419422
dir = xstrdup(argv[1]);
@@ -514,7 +517,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
514517

515518
strbuf_reset(&value);
516519

517-
if (path && !is_bundle) {
520+
if (is_local) {
518521
refs = clone_local(path, git_dir);
519522
mapped_refs = wanted_peer_refs(refs, refspec);
520523
} else {

0 commit comments

Comments
 (0)