summaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-05-07 03:47:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-05-07 03:47:38 (GMT)
commita850356d1b29ad915acb9f9e144867e90db16da3 (patch)
tree3e7f5ae3454e4fedc17d561a8f2845ab038d71ef /refs
parente5d99d378bc8207d7fccab678be7e7135f0606d1 (diff)
parent34c319970d1ccdeaa612fccdfa3e6a5f2847f1e7 (diff)
downloadgit-a850356d1b29ad915acb9f9e144867e90db16da3.zip
git-a850356d1b29ad915acb9f9e144867e90db16da3.tar.gz
git-a850356d1b29ad915acb9f9e144867e90db16da3.tar.bz2
Merge branch 'hn/trace-reflog-expiry'
The reflog expiry machinery has been taught to emit trace events. * hn/trace-reflog-expiry: refs/debug: trace into reflog expiry too
Diffstat (limited to 'refs')
-rw-r--r--refs/debug.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/refs/debug.c b/refs/debug.c
index 576bf98..001e306 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -356,6 +356,40 @@ static int debug_delete_reflog(struct ref_store *ref_store, const char *refname)
return res;
}
+struct debug_reflog_expiry_should_prune {
+ reflog_expiry_prepare_fn *prepare;
+ reflog_expiry_should_prune_fn *should_prune;
+ reflog_expiry_cleanup_fn *cleanup;
+ void *cb_data;
+};
+
+static void debug_reflog_expiry_prepare(const char *refname,
+ const struct object_id *oid,
+ void *cb_data)
+{
+ struct debug_reflog_expiry_should_prune *prune = cb_data;
+ trace_printf_key(&trace_refs, "reflog_expire_prepare: %s\n", refname);
+ prune->prepare(refname, oid, prune->cb_data);
+}
+
+static int debug_reflog_expiry_should_prune_fn(struct object_id *ooid,
+ struct object_id *noid,
+ const char *email,
+ timestamp_t timestamp, int tz,
+ const char *message, void *cb_data) {
+ struct debug_reflog_expiry_should_prune *prune = cb_data;
+
+ int result = prune->should_prune(ooid, noid, email, timestamp, tz, message, prune->cb_data);
+ trace_printf_key(&trace_refs, "reflog_expire_should_prune: %s %ld: %d\n", message, (long int) timestamp, result);
+ return result;
+}
+
+static void debug_reflog_expiry_cleanup(void *cb_data)
+{
+ struct debug_reflog_expiry_should_prune *prune = cb_data;
+ prune->cleanup(prune->cb_data);
+}
+
static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
const struct object_id *oid, unsigned int flags,
reflog_expiry_prepare_fn prepare_fn,
@@ -364,10 +398,17 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
void *policy_cb_data)
{
struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
+ struct debug_reflog_expiry_should_prune prune = {
+ .prepare = prepare_fn,
+ .cleanup = cleanup_fn,
+ .should_prune = should_prune_fn,
+ .cb_data = policy_cb_data,
+ };
int res = drefs->refs->be->reflog_expire(drefs->refs, refname, oid,
- flags, prepare_fn,
- should_prune_fn, cleanup_fn,
- policy_cb_data);
+ flags, &debug_reflog_expiry_prepare,
+ &debug_reflog_expiry_should_prune_fn,
+ &debug_reflog_expiry_cleanup,
+ &prune);
trace_printf_key(&trace_refs, "reflog_expire: %s: %d\n", refname, res);
return res;
}