@@ -573,15 +573,11 @@ static int do_plain_rerere(struct string_list *rr, int fd)
573
573
return write_rr (rr , fd );
574
574
}
575
575
576
- static int git_rerere_config (const char * var , const char * value , void * cb )
576
+ static void git_rerere_config (void )
577
577
{
578
- if (!strcmp (var , "rerere.enabled" ))
579
- rerere_enabled = git_config_bool (var , value );
580
- else if (!strcmp (var , "rerere.autoupdate" ))
581
- rerere_autoupdate = git_config_bool (var , value );
582
- else
583
- return git_default_config (var , value , cb );
584
- return 0 ;
578
+ git_config_get_bool ("rerere.enabled" , & rerere_enabled );
579
+ git_config_get_bool ("rerere.autoupdate" , & rerere_autoupdate );
580
+ git_config (git_default_config , NULL );
585
581
}
586
582
587
583
static int is_rerere_enabled (void )
@@ -606,7 +602,7 @@ int setup_rerere(struct string_list *merge_rr, int flags)
606
602
{
607
603
int fd ;
608
604
609
- git_config ( git_rerere_config , NULL );
605
+ git_rerere_config ( );
610
606
if (!is_rerere_enabled ())
611
607
return -1 ;
612
608
@@ -699,34 +695,19 @@ static void unlink_rr_item(const char *name)
699
695
rmdir (git_path ("rr-cache/%s" , name ));
700
696
}
701
697
702
- struct rerere_gc_config_cb {
703
- int cutoff_noresolve ;
704
- int cutoff_resolve ;
705
- };
706
-
707
- static int git_rerere_gc_config (const char * var , const char * value , void * cb )
708
- {
709
- struct rerere_gc_config_cb * cf = cb ;
710
-
711
- if (!strcmp (var , "gc.rerereresolved" ))
712
- cf -> cutoff_resolve = git_config_int (var , value );
713
- else if (!strcmp (var , "gc.rerereunresolved" ))
714
- cf -> cutoff_noresolve = git_config_int (var , value );
715
- else
716
- return git_default_config (var , value , cb );
717
- return 0 ;
718
- }
719
-
720
698
void rerere_gc (struct string_list * rr )
721
699
{
722
700
struct string_list to_remove = STRING_LIST_INIT_DUP ;
723
701
DIR * dir ;
724
702
struct dirent * e ;
725
703
int i , cutoff ;
726
704
time_t now = time (NULL ), then ;
727
- struct rerere_gc_config_cb cf = { 15 , 60 };
705
+ int cutoff_noresolve = 15 ;
706
+ int cutoff_resolve = 60 ;
728
707
729
- git_config (git_rerere_gc_config , & cf );
708
+ git_config_get_int ("gc.rerereresolved" , & cutoff_resolve );
709
+ git_config_get_int ("gc.rerereunresolved" , & cutoff_noresolve );
710
+ git_config (git_default_config , NULL );
730
711
dir = opendir (git_path ("rr-cache" ));
731
712
if (!dir )
732
713
die_errno ("unable to open rr-cache directory" );
@@ -736,12 +717,12 @@ void rerere_gc(struct string_list *rr)
736
717
737
718
then = rerere_last_used_at (e -> d_name );
738
719
if (then ) {
739
- cutoff = cf . cutoff_resolve ;
720
+ cutoff = cutoff_resolve ;
740
721
} else {
741
722
then = rerere_created_at (e -> d_name );
742
723
if (!then )
743
724
continue ;
744
- cutoff = cf . cutoff_noresolve ;
725
+ cutoff = cutoff_noresolve ;
745
726
}
746
727
if (then < now - cutoff * 86400 )
747
728
string_list_append (& to_remove , e -> d_name );
0 commit comments