summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/clone.c11
-rwxr-xr-xt/t5601-clone.sh7
2 files changed, 16 insertions, 2 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 0b182cefc2..71ee68b464 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"));
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 1d1c8755ea..c226cff52c 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -340,4 +340,11 @@ test_expect_success 'clone from a repository with two identical branches' '
'
+test_expect_success 'shallow clone locally' '
+ git clone --depth=1 --no-local src ssrrcc &&
+ git clone ssrrcc ddsstt &&
+ test_cmp ssrrcc/.git/shallow ddsstt/.git/shallow &&
+ ( cd ddsstt && git fsck )
+'
+
test_done