]> git.ipfire.org Git - thirdparty/git.git/commitdiff
clone: --bundle-uri cannot be combined with --depth
authorDerrick Stolee <derrickstolee@github.com>
Tue, 9 Aug 2022 13:11:43 +0000 (13:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Aug 2022 21:07:37 +0000 (14:07 -0700)
A previous change added the '--bundle-uri' option, but did not check
if the --depth parameter was included. Since bundles are not compatible
with shallow clones, provide an error message to the user who is
attempting this combination.

I am leaving this as its own change, separate from the one that
implements '--bundle-uri', because this is more of an advisory for the
user. There is nothing wrong with bootstrapping with bundles and then
fetching a shallow clone. However, that is likely going to involve too
much work for the client _and_ the server. The client will download all
of this bundle information containing the full history of the
repository only to ignore most of it. The server will get a shallow
fetch request, but with a list of haves that might cause a more painful
computation of that shallow pack-file.

Reviewed-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-clone.txt
builtin/clone.c
t/t5606-clone-options.sh

index 60fedf7eb5ebfbdfce710dc35f67f22f6da55ac7..d032d971dd7ab6a52c5a0941b5a7175baab6a734 100644 (file)
@@ -327,7 +327,8 @@ or `--mirror` is given)
        Before fetching from the remote, fetch a bundle from the given
        `<uri>` and unbundle the data into the local repository. The refs
        in the bundle will be stored under the hidden `refs/bundle/*`
-       namespace.
+       namespace. This option is incompatible with `--depth`,
+       `--shallow-since`, and `--shallow-exclude`.
 
 :git-clone: 1
 include::urls.txt[]
index 4224d56275897f87c7c1319352ce6b7cc4971acc..4463789680bdb901993eb6f74fd9932dae4e7c36 100644 (file)
@@ -937,6 +937,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                option_no_checkout = 1;
        }
 
+       if (bundle_uri && deepen)
+               die(_("--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-exclude"));
+
        repo_name = argv[0];
 
        path = get_repo_path(repo_name, &is_bundle);
index 8f676d6b0c0e2f6f72b2c0285afaca5b16be3017..f6bb02ab947c1de61484e95e0f4a6228a16da103 100755 (executable)
@@ -58,6 +58,14 @@ test_expect_success 'disallows --bare with --separate-git-dir' '
 
 '
 
+test_expect_success 'disallows --bundle-uri with shallow options' '
+       for option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD
+       do
+               test_must_fail git clone --bundle-uri=bundle $option from to 2>err &&
+               grep "bundle-uri is incompatible" err || return 1
+       done
+'
+
 test_expect_success 'reject cloning shallow repository' '
        test_when_finished "rm -rf repo" &&
        test_must_fail git clone --reject-shallow shallow-repo out 2>err &&