Git fork

builtin/gc: move rerere garbage collection into separate function

In a subsequent commit we are going to introduce a new "rerere-gc" task
for git-maintenance(1). To prepare for this, refactor the code that
spawns `git rerere gc` into a separate function.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
255251cc ec314746

+11 -5
+11 -5
builtin/gc.c
··· 384 384 return should_prune; 385 385 } 386 386 387 + static int maintenance_task_rerere_gc(struct maintenance_run_opts *opts UNUSED, 388 + struct gc_config *cfg UNUSED) 389 + { 390 + struct child_process rerere_cmd = CHILD_PROCESS_INIT; 391 + rerere_cmd.git_cmd = 1; 392 + strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL); 393 + return run_command(&rerere_cmd); 394 + } 395 + 387 396 static int too_many_loose_objects(struct gc_config *cfg) 388 397 { 389 398 /* ··· 785 794 int daemonized = 0; 786 795 int keep_largest_pack = -1; 787 796 timestamp_t dummy; 788 - struct child_process rerere_cmd = CHILD_PROCESS_INIT; 789 797 struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT; 790 798 struct gc_config cfg = GC_CONFIG_INIT; 791 799 const char *prune_expire_sentinel = "sentinel"; ··· 968 976 maintenance_task_worktree_prune(&opts, &cfg)) 969 977 die(FAILED_RUN, "worktree"); 970 978 971 - rerere_cmd.git_cmd = 1; 972 - strvec_pushl(&rerere_cmd.args, "rerere", "gc", NULL); 973 - if (run_command(&rerere_cmd)) 974 - die(FAILED_RUN, rerere_cmd.args.v[0]); 979 + if (maintenance_task_rerere_gc(&opts, &cfg)) 980 + die(FAILED_RUN, "rerere"); 975 981 976 982 report_garbage = report_pack_garbage; 977 983 reprepare_packed_git(the_repository);