Merge branch 'ds/sparse-cone'
Management of sparsely checked-out working tree has gained a dedicated "sparse-checkout" command. * ds/sparse-cone: (21 commits) sparse-checkout: improve OS ls compatibility sparse-checkout: respect core.ignoreCase in cone mode sparse-checkout: check for dirty status sparse-checkout: update working directory in-process for 'init' sparse-checkout: cone mode should not interact with .gitignore sparse-checkout: write using lockfile sparse-checkout: use in-process update for disable subcommand sparse-checkout: update working directory in-process sparse-checkout: sanitize for nested folders unpack-trees: add progress to clear_ce_flags() unpack-trees: hash less in cone mode sparse-checkout: init and set in cone mode sparse-checkout: use hashmaps for cone patterns sparse-checkout: add 'cone' mode trace2: add region in clear_ce_flags sparse-checkout: create 'disable' subcommand sparse-checkout: add '--stdin' option to set subcommand sparse-checkout: 'set' subcommand clone: add --sparse mode sparse-checkout: create 'init' subcommand ...
This commit is contained in:
@ -59,6 +59,7 @@ static const char *real_git_dir;
|
||||
static char *option_upload_pack = "git-upload-pack";
|
||||
static int option_verbosity;
|
||||
static int option_progress = -1;
|
||||
static int option_sparse_checkout;
|
||||
static enum transport_family family;
|
||||
static struct string_list option_config = STRING_LIST_INIT_NODUP;
|
||||
static struct string_list option_required_reference = STRING_LIST_INIT_NODUP;
|
||||
@ -146,6 +147,8 @@ static struct option builtin_clone_options[] = {
|
||||
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
|
||||
OPT_BOOL(0, "remote-submodules", &option_remote_submodules,
|
||||
N_("any cloned submodules will use their remote-tracking branch")),
|
||||
OPT_BOOL(0, "sparse", &option_sparse_checkout,
|
||||
N_("initialize sparse-checkout file to include only files at root")),
|
||||
OPT_END()
|
||||
};
|
||||
|
||||
@ -733,6 +736,27 @@ static void update_head(const struct ref *our, const struct ref *remote,
|
||||
}
|
||||
}
|
||||
|
||||
static int git_sparse_checkout_init(const char *repo)
|
||||
{
|
||||
struct argv_array argv = ARGV_ARRAY_INIT;
|
||||
int result = 0;
|
||||
argv_array_pushl(&argv, "-C", repo, "sparse-checkout", "init", NULL);
|
||||
|
||||
/*
|
||||
* We must apply the setting in the current process
|
||||
* for the later checkout to use the sparse-checkout file.
|
||||
*/
|
||||
core_apply_sparse_checkout = 1;
|
||||
|
||||
if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
|
||||
error(_("failed to initialize sparse-checkout"));
|
||||
result = 1;
|
||||
}
|
||||
|
||||
argv_array_clear(&argv);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int checkout(int submodule_progress)
|
||||
{
|
||||
struct object_id oid;
|
||||
@ -1104,6 +1128,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
if (option_required_reference.nr || option_optional_reference.nr)
|
||||
setup_reference();
|
||||
|
||||
if (option_sparse_checkout && git_sparse_checkout_init(repo))
|
||||
return 1;
|
||||
|
||||
remote = remote_get(option_origin);
|
||||
|
||||
strbuf_addf(&default_refspec, "+%s*:%s*", src_ref_prefix,
|
||||
|
Reference in New Issue
Block a user