@@ -167,9 +167,11 @@ static void gc_config(void)
167
167
struct maintenance_run_opts ;
168
168
static int maintenance_task_pack_refs (MAYBE_UNUSED struct maintenance_run_opts * opts )
169
169
{
170
- const char * argv [] = { "pack-refs" , "--all" , "--prune" , NULL } ;
170
+ struct child_process cmd = CHILD_PROCESS_INIT ;
171
171
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 );
173
175
}
174
176
175
177
static int too_many_loose_objects (void )
@@ -535,8 +537,14 @@ static void gc_before_repack(void)
535
537
if (pack_refs && maintenance_task_pack_refs (NULL ))
536
538
die (FAILED_RUN , "pack-refs" );
537
539
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
+ }
540
548
}
541
549
542
550
int 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)
550
558
int daemonized = 0 ;
551
559
int keep_largest_pack = -1 ;
552
560
timestamp_t dummy ;
561
+ struct child_process rerere_cmd = CHILD_PROCESS_INIT ;
553
562
554
563
struct option builtin_gc_options [] = {
555
564
OPT__QUIET (& quiet , N_ ("suppress progress reporting" )),
@@ -671,30 +680,44 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
671
680
gc_before_repack ();
672
681
673
682
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 ))
676
689
die (FAILED_RUN , repack .v [0 ]);
677
690
678
691
if (prune_expire ) {
692
+ struct child_process prune_cmd = CHILD_PROCESS_INIT ;
693
+
679
694
/* run `git prune` even if using cruft packs */
680
695
strvec_push (& prune , prune_expire );
681
696
if (quiet )
682
697
strvec_push (& prune , "--no-progress" );
683
698
if (has_promisor_remote ())
684
699
strvec_push (& prune ,
685
700
"--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 ))
687
704
die (FAILED_RUN , prune .v [0 ]);
688
705
}
689
706
}
690
707
691
708
if (prune_worktrees_expire ) {
709
+ struct child_process prune_worktrees_cmd = CHILD_PROCESS_INIT ;
710
+
692
711
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 ))
694
715
die (FAILED_RUN , prune_worktrees .v [0 ]);
695
716
}
696
717
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 ))
698
721
die (FAILED_RUN , rerere .v [0 ]);
699
722
700
723
report_garbage = report_pack_garbage ;
0 commit comments