@@ -356,6 +356,40 @@ static int debug_delete_reflog(struct ref_store *ref_store, const char *refname)
356356 return res ;
357357}
358358
359+ struct debug_reflog_expiry_should_prune {
360+ reflog_expiry_prepare_fn * prepare ;
361+ reflog_expiry_should_prune_fn * should_prune ;
362+ reflog_expiry_cleanup_fn * cleanup ;
363+ void * cb_data ;
364+ };
365+
366+ static void debug_reflog_expiry_prepare (const char * refname ,
367+ const struct object_id * oid ,
368+ void * cb_data )
369+ {
370+ struct debug_reflog_expiry_should_prune * prune = cb_data ;
371+ trace_printf_key (& trace_refs , "reflog_expire_prepare: %s\n" , refname );
372+ prune -> prepare (refname , oid , prune -> cb_data );
373+ }
374+
375+ static int debug_reflog_expiry_should_prune_fn (struct object_id * ooid ,
376+ struct object_id * noid ,
377+ const char * email ,
378+ timestamp_t timestamp , int tz ,
379+ const char * message , void * cb_data ) {
380+ struct debug_reflog_expiry_should_prune * prune = cb_data ;
381+
382+ int result = prune -> should_prune (ooid , noid , email , timestamp , tz , message , prune -> cb_data );
383+ trace_printf_key (& trace_refs , "reflog_expire_should_prune: %s %ld: %d\n" , message , (long int ) timestamp , result );
384+ return result ;
385+ }
386+
387+ static void debug_reflog_expiry_cleanup (void * cb_data )
388+ {
389+ struct debug_reflog_expiry_should_prune * prune = cb_data ;
390+ prune -> cleanup (prune -> cb_data );
391+ }
392+
359393static int debug_reflog_expire (struct ref_store * ref_store , const char * refname ,
360394 const struct object_id * oid , unsigned int flags ,
361395 reflog_expiry_prepare_fn prepare_fn ,
@@ -364,10 +398,17 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
364398 void * policy_cb_data )
365399{
366400 struct debug_ref_store * drefs = (struct debug_ref_store * )ref_store ;
401+ struct debug_reflog_expiry_should_prune prune = {
402+ .prepare = prepare_fn ,
403+ .cleanup = cleanup_fn ,
404+ .should_prune = should_prune_fn ,
405+ .cb_data = policy_cb_data ,
406+ };
367407 int res = drefs -> refs -> be -> reflog_expire (drefs -> refs , refname , oid ,
368- flags , prepare_fn ,
369- should_prune_fn , cleanup_fn ,
370- policy_cb_data );
408+ flags , & debug_reflog_expiry_prepare ,
409+ & debug_reflog_expiry_should_prune_fn ,
410+ & debug_reflog_expiry_cleanup ,
411+ & prune );
371412 trace_printf_key (& trace_refs , "reflog_expire: %s: %d\n" , refname , res );
372413 return res ;
373414}
0 commit comments