Skip to content

Commit 1e3255b

Browse files
derrickstoleegitster
authored andcommitted
clone: --bundle-uri cannot be combined with --depth
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. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aa97674 commit 1e3255b

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Documentation/git-clone.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ or `--mirror` is given)
327327
Before fetching from the remote, fetch a bundle from the given
328328
`<uri>` and unbundle the data into the local repository. The refs
329329
in the bundle will be stored under the hidden `refs/bundle/*`
330-
namespace.
330+
namespace. This option is incompatible with `--depth`,
331+
`--shallow-since`, and `--shallow-exclude`.
331332

332333
:git-clone: 1
333334
include::urls.txt[]

builtin/clone.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
937937
option_no_checkout = 1;
938938
}
939939

940+
if (bundle_uri && deepen)
941+
die(_("--bundle-uri is incompatible with --depth, --shallow-since, and --shallow-exclude"));
942+
940943
repo_name = argv[0];
941944

942945
path = get_repo_path(repo_name, &is_bundle);

t/t5606-clone-options.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ test_expect_success 'disallows --bare with --separate-git-dir' '
5858
5959
'
6060

61+
test_expect_success 'disallows --bundle-uri with shallow options' '
62+
for option in --depth=1 --shallow-since=01-01-2000 --shallow-exclude=HEAD
63+
do
64+
test_must_fail git clone --bundle-uri=bundle $option from to 2>err &&
65+
grep "bundle-uri is incompatible" err || return 1
66+
done
67+
'
68+
6169
test_expect_success 'reject cloning shallow repository' '
6270
test_when_finished "rm -rf repo" &&
6371
test_must_fail git clone --reject-shallow shallow-repo out 2>err &&

0 commit comments

Comments
 (0)