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-submodulesmaint
commit
1a88ca99db
|
@ -191,9 +191,8 @@ objects from the source repository into a pack in the cloned repository.
|
||||||
Create a 'shallow' clone with a history truncated to the
|
Create a 'shallow' clone with a history truncated to the
|
||||||
specified number of commits. Implies `--single-branch` unless
|
specified number of commits. Implies `--single-branch` unless
|
||||||
`--no-single-branch` is given to fetch the histories near the
|
`--no-single-branch` is given to fetch the histories near the
|
||||||
tips of all branches. This implies `--shallow-submodules`. If
|
tips of all branches. If you want to clone submodules shallowly,
|
||||||
you want to have a shallow superproject clone, but full submodules,
|
also pass `--shallow-submodules`.
|
||||||
also pass `--no-shallow-submodules`.
|
|
||||||
|
|
||||||
--[no-]single-branch::
|
--[no-]single-branch::
|
||||||
Clone only the history leading to the tip of a single branch,
|
Clone only the history leading to the tip of a single branch,
|
||||||
|
|
|
@ -40,7 +40,7 @@ static const char * const builtin_clone_usage[] = {
|
||||||
|
|
||||||
static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;
|
static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;
|
||||||
static int option_local = -1, option_no_hardlinks, option_shared, option_recursive;
|
static int option_local = -1, option_no_hardlinks, option_shared, option_recursive;
|
||||||
static int option_shallow_submodules = -1;
|
static int option_shallow_submodules;
|
||||||
static char *option_template, *option_depth;
|
static char *option_template, *option_depth;
|
||||||
static char *option_origin = NULL;
|
static char *option_origin = NULL;
|
||||||
static char *option_branch = NULL;
|
static char *option_branch = NULL;
|
||||||
|
@ -738,8 +738,7 @@ static int checkout(void)
|
||||||
struct argv_array args = ARGV_ARRAY_INIT;
|
struct argv_array args = ARGV_ARRAY_INIT;
|
||||||
argv_array_pushl(&args, "submodule", "update", "--init", "--recursive", NULL);
|
argv_array_pushl(&args, "submodule", "update", "--init", "--recursive", NULL);
|
||||||
|
|
||||||
if (option_shallow_submodules == 1
|
if (option_shallow_submodules == 1)
|
||||||
|| (option_shallow_submodules == -1 && option_depth))
|
|
||||||
argv_array_push(&args, "--depth=1");
|
argv_array_push(&args, "--depth=1");
|
||||||
|
|
||||||
if (max_jobs != -1)
|
if (max_jobs != -1)
|
||||||
|
|
|
@ -37,7 +37,22 @@ test_expect_success 'nonshallow clone implies nonshallow submodule' '
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'shallow clone implies shallow submodule' '
|
test_expect_success 'shallow clone with shallow submodule' '
|
||||||
|
test_when_finished "rm -rf super_clone" &&
|
||||||
|
git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone &&
|
||||||
|
(
|
||||||
|
cd super_clone &&
|
||||||
|
git log --oneline >lines &&
|
||||||
|
test_line_count = 2 lines
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
cd super_clone/sub &&
|
||||||
|
git log --oneline >lines &&
|
||||||
|
test_line_count = 1 lines
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'shallow clone does not imply shallow submodule' '
|
||||||
test_when_finished "rm -rf super_clone" &&
|
test_when_finished "rm -rf super_clone" &&
|
||||||
git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
|
git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
|
||||||
(
|
(
|
||||||
|
@ -48,7 +63,7 @@ test_expect_success 'shallow clone implies shallow submodule' '
|
||||||
(
|
(
|
||||||
cd super_clone/sub &&
|
cd super_clone/sub &&
|
||||||
git log --oneline >lines &&
|
git log --oneline >lines &&
|
||||||
test_line_count = 1 lines
|
test_line_count = 3 lines
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue