21
21
#include "object-store.h"
22
22
#include "advice.h"
23
23
#include "branch.h"
24
+ #include "list-objects-filter-options.h"
24
25
25
26
#define OPT_QUIET (1 << 0)
26
27
#define OPT_CACHED (1 << 1)
@@ -1631,6 +1632,7 @@ struct module_clone_data {
1631
1632
const char * name ;
1632
1633
const char * url ;
1633
1634
const char * depth ;
1635
+ struct list_objects_filter_options * filter_options ;
1634
1636
struct string_list reference ;
1635
1637
unsigned int quiet : 1 ;
1636
1638
unsigned int progress : 1 ;
@@ -1797,6 +1799,10 @@ static int clone_submodule(struct module_clone_data *clone_data)
1797
1799
strvec_push (& cp .args , "--dissociate" );
1798
1800
if (sm_gitdir && * sm_gitdir )
1799
1801
strvec_pushl (& cp .args , "--separate-git-dir" , sm_gitdir , NULL );
1802
+ if (clone_data -> filter_options && clone_data -> filter_options -> choice )
1803
+ strvec_pushf (& cp .args , "--filter=%s" ,
1804
+ expand_list_objects_filter_spec (
1805
+ clone_data -> filter_options ));
1800
1806
if (clone_data -> single_branch >= 0 )
1801
1807
strvec_push (& cp .args , clone_data -> single_branch ?
1802
1808
"--single-branch" :
@@ -1853,6 +1859,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1853
1859
{
1854
1860
int dissociate = 0 , quiet = 0 , progress = 0 , require_init = 0 ;
1855
1861
struct module_clone_data clone_data = MODULE_CLONE_DATA_INIT ;
1862
+ struct list_objects_filter_options filter_options ;
1856
1863
1857
1864
struct option module_clone_options [] = {
1858
1865
OPT_STRING (0 , "prefix" , & clone_data .prefix ,
@@ -1882,30 +1889,34 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1882
1889
N_ ("disallow cloning into non-empty directory" )),
1883
1890
OPT_BOOL (0 , "single-branch" , & clone_data .single_branch ,
1884
1891
N_ ("clone only one branch, HEAD or --branch" )),
1892
+ OPT_PARSE_LIST_OBJECTS_FILTER (& filter_options ),
1885
1893
OPT_END ()
1886
1894
};
1887
1895
1888
1896
const char * const git_submodule_helper_usage [] = {
1889
1897
N_ ("git submodule--helper clone [--prefix=<path>] [--quiet] "
1890
1898
"[--reference <repository>] [--name <name>] [--depth <depth>] "
1891
- "[--single-branch] "
1899
+ "[--single-branch] [--filter <filter-spec>] "
1892
1900
"--url <url> --path <path>" ),
1893
1901
NULL
1894
1902
};
1895
1903
1904
+ memset (& filter_options , 0 , sizeof (filter_options ));
1896
1905
argc = parse_options (argc , argv , prefix , module_clone_options ,
1897
1906
git_submodule_helper_usage , 0 );
1898
1907
1899
1908
clone_data .dissociate = !!dissociate ;
1900
1909
clone_data .quiet = !!quiet ;
1901
1910
clone_data .progress = !!progress ;
1902
1911
clone_data .require_init = !!require_init ;
1912
+ clone_data .filter_options = & filter_options ;
1903
1913
1904
1914
if (argc || !clone_data .url || !clone_data .path || !* (clone_data .path ))
1905
1915
usage_with_options (git_submodule_helper_usage ,
1906
1916
module_clone_options );
1907
1917
1908
1918
clone_submodule (& clone_data );
1919
+ list_objects_filter_release (& filter_options );
1909
1920
return 0 ;
1910
1921
}
1911
1922
@@ -1995,6 +2006,7 @@ struct submodule_update_clone {
1995
2006
const char * recursive_prefix ;
1996
2007
const char * prefix ;
1997
2008
int single_branch ;
2009
+ struct list_objects_filter_options * filter_options ;
1998
2010
1999
2011
/* to be consumed by git-submodule.sh */
2000
2012
struct update_clone_data * update_clone ;
@@ -2155,6 +2167,9 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
2155
2167
strvec_pushl (& child -> args , "--prefix" , suc -> prefix , NULL );
2156
2168
if (suc -> recommend_shallow && sub -> recommend_shallow == 1 )
2157
2169
strvec_push (& child -> args , "--depth=1" );
2170
+ if (suc -> filter_options && suc -> filter_options -> choice )
2171
+ strvec_pushf (& child -> args , "--filter=%s" ,
2172
+ expand_list_objects_filter_spec (suc -> filter_options ));
2158
2173
if (suc -> require_init )
2159
2174
strvec_push (& child -> args , "--require-init" );
2160
2175
strvec_pushl (& child -> args , "--path" , sub -> path , NULL );
@@ -2499,6 +2514,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
2499
2514
const char * update = NULL ;
2500
2515
struct pathspec pathspec ;
2501
2516
struct submodule_update_clone suc = SUBMODULE_UPDATE_CLONE_INIT ;
2517
+ struct list_objects_filter_options filter_options ;
2518
+ int ret ;
2502
2519
2503
2520
struct option module_update_clone_options [] = {
2504
2521
OPT_STRING (0 , "prefix" , & prefix ,
@@ -2529,6 +2546,7 @@ static int update_clone(int argc, const char **argv, const char *prefix)
2529
2546
N_ ("disallow cloning into non-empty directory" )),
2530
2547
OPT_BOOL (0 , "single-branch" , & suc .single_branch ,
2531
2548
N_ ("clone only one branch, HEAD or --branch" )),
2549
+ OPT_PARSE_LIST_OBJECTS_FILTER (& filter_options ),
2532
2550
OPT_END ()
2533
2551
};
2534
2552
@@ -2541,20 +2559,26 @@ static int update_clone(int argc, const char **argv, const char *prefix)
2541
2559
update_clone_config_from_gitmodules (& suc .max_jobs );
2542
2560
git_config (git_update_clone_config , & suc .max_jobs );
2543
2561
2562
+ memset (& filter_options , 0 , sizeof (filter_options ));
2544
2563
argc = parse_options (argc , argv , prefix , module_update_clone_options ,
2545
2564
git_submodule_helper_usage , 0 );
2565
+ suc .filter_options = & filter_options ;
2546
2566
2547
2567
if (update )
2548
2568
if (parse_submodule_update_strategy (update , & suc .update ) < 0 )
2549
2569
die (_ ("bad value for update parameter" ));
2550
2570
2551
- if (module_list_compute (argc , argv , prefix , & pathspec , & suc .list ) < 0 )
2571
+ if (module_list_compute (argc , argv , prefix , & pathspec , & suc .list ) < 0 ) {
2572
+ list_objects_filter_release (& filter_options );
2552
2573
return 1 ;
2574
+ }
2553
2575
2554
2576
if (pathspec .nr )
2555
2577
suc .warn_if_uninitialized = 1 ;
2556
2578
2557
- return update_submodules (& suc );
2579
+ ret = update_submodules (& suc );
2580
+ list_objects_filter_release (& filter_options );
2581
+ return ret ;
2558
2582
}
2559
2583
2560
2584
static int run_update_procedure (int argc , const char * * argv , const char * prefix )
0 commit comments