20
#include "diff.h"
21
#include "object-store.h"
22
#include "advice.h"
23
+#include "list-objects-filter-options.h"
24
25
#define OPT_QUIET (1 << 0)
26
#define OPT_CACHED (1 << 1)
1631
const char *name;
1632
const char *url;
1633
const char *depth;
1634
+ struct list_objects_filter_options *filter_options;
1635
struct string_list reference;
1636
unsigned int quiet: 1;
1637
unsigned int progress: 1;
1798
strvec_push(&cp.args, "--dissociate");
1799
if (sm_gitdir && *sm_gitdir)
1800
strvec_pushl(&cp.args, "--separate-git-dir", sm_gitdir, NULL);
1801
+ if (clone_data->filter_options && clone_data->filter_options->choice)
1802
+ strvec_pushf(&cp.args, "--filter=%s",
1803
+ expand_list_objects_filter_spec(
1804
+ clone_data->filter_options));
1805
if (clone_data->single_branch >= 0)
1806
strvec_push(&cp.args, clone_data->single_branch ?
1807
"--single-branch" :
1858
{
1859
int dissociate = 0, quiet = 0, progress = 0, require_init = 0;
1860
struct module_clone_data clone_data = MODULE_CLONE_DATA_INIT;
1861
+ struct list_objects_filter_options filter_options;
1862
1863
struct option module_clone_options[] = {
1864
OPT_STRING(0, "prefix", &clone_data.prefix,
1888
N_("disallow cloning into non-empty directory")),
1889
OPT_BOOL(0, "single-branch", &clone_data.single_branch,
1890
N_("clone only one branch, HEAD or --branch")),
1891
+ OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
1892
OPT_END()
1893
};
1894
1895
const char *const git_submodule_helper_usage[] = {
1896
N_("git submodule--helper clone [--prefix=<path>] [--quiet] "
1897
"[--reference <repository>] [--name <name>] [--depth <depth>] "
1890
- "[--single-branch] "
1898
+ "[--single-branch] [--filter <filter-spec>]"
1899
"--url <url> --path <path>"),
1900
NULL
1901
};
1902
1903
+ memset(&filter_options, 0, sizeof(filter_options));
1904
argc = parse_options(argc, argv, prefix, module_clone_options,
1905
git_submodule_helper_usage, 0);
1906
1908
clone_data.quiet = !!quiet;
1909
clone_data.progress = !!progress;
1910
clone_data.require_init = !!require_init;
1911
+ clone_data.filter_options = &filter_options;
1912
1913
if (argc || !clone_data.url || !clone_data.path || !*(clone_data.path))
1914
usage_with_options(git_submodule_helper_usage,
1915
module_clone_options);
1916
1917
clone_submodule(&clone_data);
1918
+ list_objects_filter_release(&filter_options);
1919
return 0;
1920
}
1921
2005
const char *recursive_prefix;
2006
const char *prefix;
2007
int single_branch;
2008
+ struct list_objects_filter_options *filter_options;
2009
2010
/* to be consumed by git-submodule.sh */
2011
struct update_clone_data *update_clone;
2166
strvec_pushl(&child->args, "--prefix", suc->prefix, NULL);
2167
if (suc->recommend_shallow && sub->recommend_shallow == 1)
2168
strvec_push(&child->args, "--depth=1");
2169
+ if (suc->filter_options && suc->filter_options->choice)
2170
+ strvec_pushf(&child->args, "--filter=%s",
2171
+ expand_list_objects_filter_spec(suc->filter_options));
2172
if (suc->require_init)
2173
strvec_push(&child->args, "--require-init");
2174
strvec_pushl(&child->args, "--path", sub->path, NULL);
2513
const char *update = NULL;
2514
struct pathspec pathspec;
2515
struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT;
2516
+ struct list_objects_filter_options filter_options;
2517
+ int ret;
2518
2519
struct option module_update_clone_options[] = {
2520
OPT_STRING(0, "prefix", &prefix,
2545
N_("disallow cloning into non-empty directory")),
2546
OPT_BOOL(0, "single-branch", &suc.single_branch,
2547
N_("clone only one branch, HEAD or --branch")),
2548
+ OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
2549
OPT_END()
2550
};
2551
2558
update_clone_config_from_gitmodules(&suc.max_jobs);
2559
git_config(git_update_clone_config, &suc.max_jobs);
2560
2561
+ memset(&filter_options, 0, sizeof(filter_options));
2562
argc = parse_options(argc, argv, prefix, module_update_clone_options,
2563
git_submodule_helper_usage, 0);
2564
+ suc.filter_options = &filter_options;
2565
2566
if (update)
2567
if (parse_submodule_update_strategy(update, &suc.update) < 0)
2568
die(_("bad value for update parameter"));
2569
2550
- if (module_list_compute(argc, argv, prefix, &pathspec, &suc.list) < 0)
2570
+ if (module_list_compute(argc, argv, prefix, &pathspec, &suc.list) < 0) {
2571
+ list_objects_filter_release(&filter_options);
2572
return 1;
2573
+ }
2574
2575
if (pathspec.nr)
2576
suc.warn_if_uninitialized = 1;
2577
2556
- return update_submodules(&suc);
2578
+ ret = update_submodules(&suc);
2579
+ list_objects_filter_release(&filter_options);
2580
+ return ret;
2581
}
2582
2583
static int run_update_procedure(int argc, const char **argv, const char *prefix)