Skip to content

Commit 1a88ca9

Browse files
committed
Merge branch 'sb/clone-shallow-passthru' into maint
Fix an unintended regression in v2.9 that breaks "clone --depth" that recurses down to submodules by forcing the submodules to also be cloned shallowly, which many server instances that host upstream of the submodules are not prepared for. * sb/clone-shallow-passthru: clone: do not let --depth imply --shallow-submodules
2 parents 4212e48 + 18a74a0 commit 1a88ca9

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

Documentation/git-clone.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@ objects from the source repository into a pack in the cloned repository.
191191
Create a 'shallow' clone with a history truncated to the
192192
specified number of commits. Implies `--single-branch` unless
193193
`--no-single-branch` is given to fetch the histories near the
194-
tips of all branches. This implies `--shallow-submodules`. If
195-
you want to have a shallow superproject clone, but full submodules,
196-
also pass `--no-shallow-submodules`.
194+
tips of all branches. If you want to clone submodules shallowly,
195+
also pass `--shallow-submodules`.
197196

198197
--[no-]single-branch::
199198
Clone only the history leading to the tip of a single branch,

builtin/clone.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static const char * const builtin_clone_usage[] = {
4040

4141
static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;
4242
static int option_local = -1, option_no_hardlinks, option_shared, option_recursive;
43-
static int option_shallow_submodules = -1;
43+
static int option_shallow_submodules;
4444
static char *option_template, *option_depth;
4545
static char *option_origin = NULL;
4646
static char *option_branch = NULL;
@@ -738,8 +738,7 @@ static int checkout(void)
738738
struct argv_array args = ARGV_ARRAY_INIT;
739739
argv_array_pushl(&args, "submodule", "update", "--init", "--recursive", NULL);
740740

741-
if (option_shallow_submodules == 1
742-
|| (option_shallow_submodules == -1 && option_depth))
741+
if (option_shallow_submodules == 1)
743742
argv_array_push(&args, "--depth=1");
744743

745744
if (max_jobs != -1)

t/t5614-clone-submodules.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ test_expect_success 'nonshallow clone implies nonshallow submodule' '
3737
)
3838
'
3939

40-
test_expect_success 'shallow clone implies shallow submodule' '
40+
test_expect_success 'shallow clone with shallow submodule' '
4141
test_when_finished "rm -rf super_clone" &&
42-
git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
42+
git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone &&
4343
(
4444
cd super_clone &&
4545
git log --oneline >lines &&
@@ -52,6 +52,21 @@ test_expect_success 'shallow clone implies shallow submodule' '
5252
)
5353
'
5454

55+
test_expect_success 'shallow clone does not imply shallow submodule' '
56+
test_when_finished "rm -rf super_clone" &&
57+
git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
58+
(
59+
cd super_clone &&
60+
git log --oneline >lines &&
61+
test_line_count = 2 lines
62+
) &&
63+
(
64+
cd super_clone/sub &&
65+
git log --oneline >lines &&
66+
test_line_count = 3 lines
67+
)
68+
'
69+
5570
test_expect_success 'shallow clone with non shallow submodule' '
5671
test_when_finished "rm -rf super_clone" &&
5772
git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone &&

0 commit comments

Comments
 (0)