@@ -13,7 +13,8 @@ static char const * const builtin_commit_graph_usage[] = {
1313 N_ ("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress]" ),
1414 N_ ("git commit-graph write [--object-dir <objdir>] [--append] "
1515 "[--split[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
16- "[--changed-paths] [--[no-]progress] <split options>" ),
16+ "[--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress] "
17+ "<split options>" ),
1718 NULL
1819};
1920
@@ -25,7 +26,8 @@ static const char * const builtin_commit_graph_verify_usage[] = {
2526static const char * const builtin_commit_graph_write_usage [] = {
2627 N_ ("git commit-graph write [--object-dir <objdir>] [--append] "
2728 "[--split[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
28- "[--changed-paths] [--[no-]progress] <split options>" ),
29+ "[--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress] "
30+ "<split options>" ),
2931 NULL
3032};
3133
@@ -106,7 +108,7 @@ static int graph_verify(int argc, const char **argv)
106108 FREE_AND_NULL (graph_name );
107109
108110 if (open_ok )
109- graph = load_commit_graph_one_fd_st (fd , & st , odb );
111+ graph = load_commit_graph_one_fd_st (the_repository , fd , & st , odb );
110112 else
111113 graph = read_commit_graph_one (the_repository , odb );
112114
@@ -119,7 +121,7 @@ static int graph_verify(int argc, const char **argv)
119121}
120122
121123extern int read_replace_refs ;
122- static struct split_commit_graph_opts split_opts ;
124+ static struct commit_graph_opts write_opts ;
123125
124126static int write_option_parse_split (const struct option * opt , const char * arg ,
125127 int unset )
@@ -162,6 +164,35 @@ static int read_one_commit(struct oidset *commits, struct progress *progress,
162164 return 0 ;
163165}
164166
167+ static int write_option_max_new_filters (const struct option * opt ,
168+ const char * arg ,
169+ int unset )
170+ {
171+ int * to = opt -> value ;
172+ if (unset )
173+ * to = -1 ;
174+ else {
175+ const char * s ;
176+ * to = strtol (arg , (char * * )& s , 10 );
177+ if (* s )
178+ return error (_ ("%s expects a numerical value" ),
179+ optname (opt , opt -> flags ));
180+ }
181+ return 0 ;
182+ }
183+
184+ static int git_commit_graph_write_config (const char * var , const char * value ,
185+ void * cb )
186+ {
187+ if (!strcmp (var , "commitgraph.maxnewfilters" ))
188+ write_opts .max_new_filters = git_config_int (var , value );
189+ /*
190+ * No need to fall-back to 'git_default_config', since this was already
191+ * called in 'cmd_commit_graph()'.
192+ */
193+ return 0 ;
194+ }
195+
165196static int graph_write (int argc , const char * * argv )
166197{
167198 struct string_list pack_indexes = STRING_LIST_INIT_NODUP ;
@@ -187,27 +218,33 @@ static int graph_write(int argc, const char **argv)
187218 OPT_BOOL (0 , "changed-paths" , & opts .enable_changed_paths ,
188219 N_ ("enable computation for changed paths" )),
189220 OPT_BOOL (0 , "progress" , & opts .progress , N_ ("force progress reporting" )),
190- OPT_CALLBACK_F (0 , "split" , & split_opts . flags , NULL ,
221+ OPT_CALLBACK_F (0 , "split" , & write_opts . split_flags , NULL ,
191222 N_ ("allow writing an incremental commit-graph file" ),
192223 PARSE_OPT_OPTARG | PARSE_OPT_NONEG ,
193224 write_option_parse_split ),
194- OPT_INTEGER (0 , "max-commits" , & split_opts .max_commits ,
225+ OPT_INTEGER (0 , "max-commits" , & write_opts .max_commits ,
195226 N_ ("maximum number of commits in a non-base split commit-graph" )),
196- OPT_INTEGER (0 , "size-multiple" , & split_opts .size_multiple ,
227+ OPT_INTEGER (0 , "size-multiple" , & write_opts .size_multiple ,
197228 N_ ("maximum ratio between two levels of a split commit-graph" )),
198- OPT_EXPIRY_DATE (0 , "expire-time" , & split_opts .expire_time ,
229+ OPT_EXPIRY_DATE (0 , "expire-time" , & write_opts .expire_time ,
199230 N_ ("only expire files older than a given date-time" )),
231+ OPT_CALLBACK_F (0 , "max-new-filters" , & write_opts .max_new_filters ,
232+ NULL , N_ ("maximum number of changed-path Bloom filters to compute" ),
233+ 0 , write_option_max_new_filters ),
200234 OPT_END (),
201235 };
202236
203237 opts .progress = isatty (2 );
204238 opts .enable_changed_paths = -1 ;
205- split_opts .size_multiple = 2 ;
206- split_opts .max_commits = 0 ;
207- split_opts .expire_time = 0 ;
239+ write_opts .size_multiple = 2 ;
240+ write_opts .max_commits = 0 ;
241+ write_opts .expire_time = 0 ;
242+ write_opts .max_new_filters = -1 ;
208243
209244 trace2_cmd_mode ("write" );
210245
246+ git_config (git_commit_graph_write_config , & opts );
247+
211248 argc = parse_options (argc , argv , NULL ,
212249 builtin_commit_graph_write_options ,
213250 builtin_commit_graph_write_usage , 0 );
@@ -232,7 +269,7 @@ static int graph_write(int argc, const char **argv)
232269 odb = find_odb (the_repository , opts .obj_dir );
233270
234271 if (opts .reachable ) {
235- if (write_commit_graph_reachable (odb , flags , & split_opts ))
272+ if (write_commit_graph_reachable (odb , flags , & write_opts ))
236273 return 1 ;
237274 return 0 ;
238275 }
@@ -261,7 +298,7 @@ static int graph_write(int argc, const char **argv)
261298 opts .stdin_packs ? & pack_indexes : NULL ,
262299 opts .stdin_commits ? & commits : NULL ,
263300 flags ,
264- & split_opts ))
301+ & write_opts ))
265302 result = 1 ;
266303
267304cleanup :
0 commit comments