When cloning locally, we default to --local, as it makes the whole operation fast and efficient. As the most common intent of cloning with a --depth parameter is to save space, and --local saves space more than --depth ever can, warn the user and ignore the --depth parameter when cloning locally. Should --depth be desired, the user can always force proper cloning by using a file:// URL. Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> --- Before making git-clone a builtin, we had code to force a clone when a --depth parameter was passed. However, it is dubitable that a user wants --depth rather than --local, and as in the --local case, we should cater for the common case. Documentation/git-clone.txt | 4 ++++ builtin-clone.c | 5 ++++- t/t5701-clone-local.sh | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletions(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 95f08b9..9b8b389 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -138,6 +138,10 @@ then the cloned repository will become corrupt. are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches. ++ +This option is ignored when cloning locally; to force a shallow +clone even locally, use the `--no-hardlinks` option, or a +'file://' location. <repository>:: The (possibly remote) repository to clone from. See the diff --git a/builtin-clone.c b/builtin-clone.c index c338910..5831034 100644 --- a/builtin-clone.c +++ b/builtin-clone.c @@ -511,8 +511,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix) refspec.src = src_ref_prefix; refspec.dst = branch_top.buf; - if (path && !is_bundle) + if (path && !is_bundle) { + if (option_depth) + warning("Ignoring --depth for local clone"); refs = clone_local(path, git_dir); + } else { struct remote *remote = remote_get(argv[0]); transport = transport_get(remote, remote->url[0]); diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh index 3559d17..2938c02 100755 --- a/t/t5701-clone-local.sh +++ b/t/t5701-clone-local.sh @@ -132,4 +132,11 @@ test_expect_success 'clone empty repository' ' test $actual = $expected) ' +test_expect_success 'clone --depth locally ignores --depth' ' + test_commit meredith chivers && + git clone --depth 1 . depth 2> out.err && + grep "warning: Ignoring --depth for local clone" out.err && + test 1 -lt $(cd depth && git rev-list master | wc -l) +' + test_done -- 1.6.2.rc1.350.g6caf6 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html