@@ -353,6 +353,40 @@ static int debug_delete_reflog(struct ref_store *ref_store, const char *refname)
353353 return res ;
354354}
355355
356+ struct debug_reflog_expiry_should_prune {
357+ reflog_expiry_prepare_fn * prepare ;
358+ reflog_expiry_should_prune_fn * should_prune ;
359+ reflog_expiry_cleanup_fn * cleanup ;
360+ void * cb_data ;
361+ };
362+
363+ static void debug_reflog_expiry_prepare (const char * refname ,
364+ const struct object_id * oid ,
365+ void * cb_data )
366+ {
367+ struct debug_reflog_expiry_should_prune * prune = cb_data ;
368+ trace_printf_key (& trace_refs , "reflog_expire_prepare: %s\n" , refname );
369+ prune -> prepare (refname , oid , prune -> cb_data );
370+ }
371+
372+ static int debug_reflog_expiry_should_prune_fn (struct object_id * ooid ,
373+ struct object_id * noid ,
374+ const char * email ,
375+ timestamp_t timestamp , int tz ,
376+ const char * message , void * cb_data ) {
377+ struct debug_reflog_expiry_should_prune * prune = cb_data ;
378+
379+ int result = prune -> should_prune (ooid , noid , email , timestamp , tz , message , prune -> cb_data );
380+ trace_printf_key (& trace_refs , "reflog_expire_should_prune: %s %ld: %d\n" , message , (long int ) timestamp , result );
381+ return result ;
382+ }
383+
384+ static void debug_reflog_expiry_cleanup (void * cb_data )
385+ {
386+ struct debug_reflog_expiry_should_prune * prune = cb_data ;
387+ prune -> cleanup (prune -> cb_data );
388+ }
389+
356390static int debug_reflog_expire (struct ref_store * ref_store , const char * refname ,
357391 const struct object_id * oid , unsigned int flags ,
358392 reflog_expiry_prepare_fn prepare_fn ,
@@ -361,10 +395,17 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
361395 void * policy_cb_data )
362396{
363397 struct debug_ref_store * drefs = (struct debug_ref_store * )ref_store ;
398+ struct debug_reflog_expiry_should_prune prune = {
399+ .prepare = prepare_fn ,
400+ .cleanup = cleanup_fn ,
401+ .should_prune = should_prune_fn ,
402+ .cb_data = policy_cb_data ,
403+ };
364404 int res = drefs -> refs -> be -> reflog_expire (drefs -> refs , refname , oid ,
365- flags , prepare_fn ,
366- should_prune_fn , cleanup_fn ,
367- policy_cb_data );
405+ flags , & debug_reflog_expiry_prepare ,
406+ & debug_reflog_expiry_should_prune_fn ,
407+ & debug_reflog_expiry_cleanup ,
408+ & prune );
368409 trace_printf_key (& trace_refs , "reflog_expire: %s: %d\n" , refname , res );
369410 return res ;
370411}
0 commit comments