@@ -438,10 +438,9 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
438438 return NULL ;
439439}
440440
441- static int report_last_gc_error (void )
441+ static void report_last_gc_error (void )
442442{
443443 struct strbuf sb = STRBUF_INIT ;
444- int ret = 0 ;
445444 ssize_t len ;
446445 struct stat st ;
447446 char * gc_log_path = git_pathdup ("gc.log" );
@@ -450,18 +449,17 @@ static int report_last_gc_error(void)
450449 if (errno == ENOENT )
451450 goto done ;
452451
453- ret = error_errno (_ ("cannot stat '%s'" ), gc_log_path );
454- goto done ;
452+ die_errno (_ ("cannot stat '%s'" ), gc_log_path );
455453 }
456454
457455 if (st .st_mtime < gc_log_expire_time )
458456 goto done ;
459457
460458 len = strbuf_read_file (& sb , gc_log_path , 0 );
461459 if (len < 0 )
462- ret = error_errno (_ ("cannot read '%s'" ), gc_log_path );
460+ die_errno (_ ("cannot read '%s'" ), gc_log_path );
463461 else if (len > 0 )
464- ret = error (_ ("The last gc run reported the following. "
462+ die (_ ("The last gc run reported the following. "
465463 "Please correct the root cause\n"
466464 "and remove %s.\n"
467465 "Automatic cleanup will not be performed "
@@ -471,20 +469,18 @@ static int report_last_gc_error(void)
471469 strbuf_release (& sb );
472470done :
473471 free (gc_log_path );
474- return ret ;
475472}
476473
477- static int gc_before_repack (void )
474+ static void gc_before_repack (void )
478475{
479476 if (pack_refs && run_command_v_opt (pack_refs_cmd .argv , RUN_GIT_CMD ))
480- return error (FAILED_RUN , pack_refs_cmd .argv [0 ]);
477+ die (FAILED_RUN , pack_refs_cmd .argv [0 ]);
481478
482479 if (prune_reflogs && run_command_v_opt (reflog .argv , RUN_GIT_CMD ))
483- return error (FAILED_RUN , reflog .argv [0 ]);
480+ die (FAILED_RUN , reflog .argv [0 ]);
484481
485482 pack_refs = 0 ;
486483 prune_reflogs = 0 ;
487- return 0 ;
488484}
489485
490486int cmd_gc (int argc , const char * * argv , const char * prefix )
@@ -565,13 +561,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
565561 fprintf (stderr , _ ("See \"git help gc\" for manual housekeeping.\n" ));
566562 }
567563 if (detach_auto ) {
568- if (report_last_gc_error ())
569- return -1 ;
564+ report_last_gc_error (); /* dies on error */
570565
571566 if (lock_repo_for_gc (force , & pid ))
572567 return 0 ;
573- if (gc_before_repack ())
574- return -1 ;
568+ gc_before_repack (); /* dies on failure */
575569 delete_tempfile (& pidfile );
576570
577571 /*
@@ -611,12 +605,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
611605 atexit (process_log_file_at_exit );
612606 }
613607
614- if (gc_before_repack ())
615- return -1 ;
608+ gc_before_repack ();
616609
617610 if (!repository_format_precious_objects ) {
618611 if (run_command_v_opt (repack .argv , RUN_GIT_CMD ))
619- return error (FAILED_RUN , repack .argv [0 ]);
612+ die (FAILED_RUN , repack .argv [0 ]);
620613
621614 if (prune_expire ) {
622615 argv_array_push (& prune , prune_expire );
@@ -626,18 +619,18 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
626619 argv_array_push (& prune ,
627620 "--exclude-promisor-objects" );
628621 if (run_command_v_opt (prune .argv , RUN_GIT_CMD ))
629- return error (FAILED_RUN , prune .argv [0 ]);
622+ die (FAILED_RUN , prune .argv [0 ]);
630623 }
631624 }
632625
633626 if (prune_worktrees_expire ) {
634627 argv_array_push (& prune_worktrees , prune_worktrees_expire );
635628 if (run_command_v_opt (prune_worktrees .argv , RUN_GIT_CMD ))
636- return error (FAILED_RUN , prune_worktrees .argv [0 ]);
629+ die (FAILED_RUN , prune_worktrees .argv [0 ]);
637630 }
638631
639632 if (run_command_v_opt (rerere .argv , RUN_GIT_CMD ))
640- return error (FAILED_RUN , rerere .argv [0 ]);
633+ die (FAILED_RUN , rerere .argv [0 ]);
641634
642635 report_garbage = report_pack_garbage ;
643636 reprepare_packed_git (the_repository );
0 commit comments