@@ -438,10 +438,9 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
438
438
return NULL ;
439
439
}
440
440
441
- static int report_last_gc_error (void )
441
+ static void report_last_gc_error (void )
442
442
{
443
443
struct strbuf sb = STRBUF_INIT ;
444
- int ret = 0 ;
445
444
ssize_t len ;
446
445
struct stat st ;
447
446
char * gc_log_path = git_pathdup ("gc.log" );
@@ -450,18 +449,17 @@ static int report_last_gc_error(void)
450
449
if (errno == ENOENT )
451
450
goto done ;
452
451
453
- ret = error_errno (_ ("cannot stat '%s'" ), gc_log_path );
454
- goto done ;
452
+ die_errno (_ ("cannot stat '%s'" ), gc_log_path );
455
453
}
456
454
457
455
if (st .st_mtime < gc_log_expire_time )
458
456
goto done ;
459
457
460
458
len = strbuf_read_file (& sb , gc_log_path , 0 );
461
459
if (len < 0 )
462
- ret = error_errno (_ ("cannot read '%s'" ), gc_log_path );
460
+ die_errno (_ ("cannot read '%s'" ), gc_log_path );
463
461
else if (len > 0 )
464
- ret = error (_ ("The last gc run reported the following. "
462
+ die (_ ("The last gc run reported the following. "
465
463
"Please correct the root cause\n"
466
464
"and remove %s.\n"
467
465
"Automatic cleanup will not be performed "
@@ -471,20 +469,18 @@ static int report_last_gc_error(void)
471
469
strbuf_release (& sb );
472
470
done :
473
471
free (gc_log_path );
474
- return ret ;
475
472
}
476
473
477
- static int gc_before_repack (void )
474
+ static void gc_before_repack (void )
478
475
{
479
476
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 ]);
481
478
482
479
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 ]);
484
481
485
482
pack_refs = 0 ;
486
483
prune_reflogs = 0 ;
487
- return 0 ;
488
484
}
489
485
490
486
int 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)
565
561
fprintf (stderr , _ ("See \"git help gc\" for manual housekeeping.\n" ));
566
562
}
567
563
if (detach_auto ) {
568
- if (report_last_gc_error ())
569
- return -1 ;
564
+ report_last_gc_error (); /* dies on error */
570
565
571
566
if (lock_repo_for_gc (force , & pid ))
572
567
return 0 ;
573
- if (gc_before_repack ())
574
- return -1 ;
568
+ gc_before_repack (); /* dies on failure */
575
569
delete_tempfile (& pidfile );
576
570
577
571
/*
@@ -611,12 +605,11 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
611
605
atexit (process_log_file_at_exit );
612
606
}
613
607
614
- if (gc_before_repack ())
615
- return -1 ;
608
+ gc_before_repack ();
616
609
617
610
if (!repository_format_precious_objects ) {
618
611
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 ]);
620
613
621
614
if (prune_expire ) {
622
615
argv_array_push (& prune , prune_expire );
@@ -626,18 +619,18 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
626
619
argv_array_push (& prune ,
627
620
"--exclude-promisor-objects" );
628
621
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 ]);
630
623
}
631
624
}
632
625
633
626
if (prune_worktrees_expire ) {
634
627
argv_array_push (& prune_worktrees , prune_worktrees_expire );
635
628
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 ]);
637
630
}
638
631
639
632
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 ]);
641
634
642
635
report_garbage = report_pack_garbage ;
643
636
reprepare_packed_git (the_repository );
0 commit comments