summaryrefslogtreecommitdiff
path: root/builtin/clone.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-12-05 13:02:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-12-11 00:14:18 (GMT)
commit0d7d285f0e29abb994fe32db87ee81b00f403bd2 (patch)
treed4faea61b13c73cdd418cdcdc1f4323fe2b1a414 /builtin/clone.c
parentf2c681cf12c54ce3859b36693f8a13c36126577b (diff)
downloadgit-0d7d285f0e29abb994fe32db87ee81b00f403bd2.zip
git-0d7d285f0e29abb994fe32db87ee81b00f403bd2.tar.gz
git-0d7d285f0e29abb994fe32db87ee81b00f403bd2.tar.bz2
clone: use git protocol for cloning shallow repo locally
clone_local() does not handle $SRC/shallow. It could be made so, but it's simpler to use fetch-pack/upload-pack instead. This used to be caught by the check in upload-pack, which is triggered by transport_get_remote_refs(), even in local clone case. The check is now gone and check_everything_connected() should catch the result incomplete repo. But check_everything_connected() will soon be skipped in local clone case, opening a door to corrupt repo. This patch should close that door. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clone.c')
-rw-r--r--builtin/clone.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 0b182ce..71ee68b 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -797,8 +797,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
else
repo = repo_name;
is_local = option_local != 0 && path && !is_bundle;
- if (is_local && option_depth)
- warning(_("--depth is ignored in local clones; use file:// instead."));
+ if (is_local) {
+ if (option_depth)
+ warning(_("--depth is ignored in local clones; use file:// instead."));
+ if (!access(mkpath("%s/shallow", path), F_OK)) {
+ if (option_local > 0)
+ warning(_("source repository is shallow, ignoring --local"));
+ is_local = 0;
+ }
+ }
if (option_local > 0 && !is_local)
warning(_("--local is ignored"));