@@ -167,9 +167,11 @@ static void gc_config(void)
167167struct maintenance_run_opts ;
168168static int maintenance_task_pack_refs (MAYBE_UNUSED struct maintenance_run_opts * opts )
169169{
170- const char * argv [] = { "pack-refs" , "--all" , "--prune" , NULL } ;
170+ struct child_process cmd = CHILD_PROCESS_INIT ;
171171
172- return run_command_v_opt (argv , RUN_GIT_CMD );
172+ cmd .git_cmd = 1 ;
173+ strvec_pushl (& cmd .args , "pack-refs" , "--all" , "--prune" , NULL );
174+ return run_command (& cmd );
173175}
174176
175177static int too_many_loose_objects (void )
@@ -535,8 +537,14 @@ static void gc_before_repack(void)
535537 if (pack_refs && maintenance_task_pack_refs (NULL ))
536538 die (FAILED_RUN , "pack-refs" );
537539
538- if (prune_reflogs && run_command_v_opt (reflog .v , RUN_GIT_CMD ))
539- die (FAILED_RUN , reflog .v [0 ]);
540+ if (prune_reflogs ) {
541+ struct child_process cmd = CHILD_PROCESS_INIT ;
542+
543+ cmd .git_cmd = 1 ;
544+ strvec_pushv (& cmd .args , reflog .v );
545+ if (run_command (& cmd ))
546+ die (FAILED_RUN , reflog .v [0 ]);
547+ }
540548}
541549
542550int cmd_gc (int argc , const char * * argv , const char * prefix )
@@ -550,6 +558,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
550558 int daemonized = 0 ;
551559 int keep_largest_pack = -1 ;
552560 timestamp_t dummy ;
561+ struct child_process rerere_cmd = CHILD_PROCESS_INIT ;
553562
554563 struct option builtin_gc_options [] = {
555564 OPT__QUIET (& quiet , N_ ("suppress progress reporting" )),
@@ -671,30 +680,44 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
671680 gc_before_repack ();
672681
673682 if (!repository_format_precious_objects ) {
674- if (run_command_v_opt (repack .v ,
675- RUN_GIT_CMD | RUN_CLOSE_OBJECT_STORE ))
683+ struct child_process repack_cmd = CHILD_PROCESS_INIT ;
684+
685+ repack_cmd .git_cmd = 1 ;
686+ repack_cmd .close_object_store = 1 ;
687+ strvec_pushv (& repack_cmd .args , repack .v );
688+ if (run_command (& repack_cmd ))
676689 die (FAILED_RUN , repack .v [0 ]);
677690
678691 if (prune_expire ) {
692+ struct child_process prune_cmd = CHILD_PROCESS_INIT ;
693+
679694 /* run `git prune` even if using cruft packs */
680695 strvec_push (& prune , prune_expire );
681696 if (quiet )
682697 strvec_push (& prune , "--no-progress" );
683698 if (has_promisor_remote ())
684699 strvec_push (& prune ,
685700 "--exclude-promisor-objects" );
686- if (run_command_v_opt (prune .v , RUN_GIT_CMD ))
701+ prune_cmd .git_cmd = 1 ;
702+ strvec_pushv (& prune_cmd .args , prune .v );
703+ if (run_command (& prune_cmd ))
687704 die (FAILED_RUN , prune .v [0 ]);
688705 }
689706 }
690707
691708 if (prune_worktrees_expire ) {
709+ struct child_process prune_worktrees_cmd = CHILD_PROCESS_INIT ;
710+
692711 strvec_push (& prune_worktrees , prune_worktrees_expire );
693- if (run_command_v_opt (prune_worktrees .v , RUN_GIT_CMD ))
712+ prune_worktrees_cmd .git_cmd = 1 ;
713+ strvec_pushv (& prune_worktrees_cmd .args , prune_worktrees .v );
714+ if (run_command (& prune_worktrees_cmd ))
694715 die (FAILED_RUN , prune_worktrees .v [0 ]);
695716 }
696717
697- if (run_command_v_opt (rerere .v , RUN_GIT_CMD ))
718+ rerere_cmd .git_cmd = 1 ;
719+ strvec_pushv (& rerere_cmd .args , rerere .v );
720+ if (run_command (& rerere_cmd ))
698721 die (FAILED_RUN , rerere .v [0 ]);
699722
700723 report_garbage = report_pack_garbage ;
0 commit comments