{"thread":{"id":"55544","subject":"[PATCH] refs/debug: trace into reflog expiry too","startedAt":"2021-04-23T09:10:44Z","lastAt":"2021-04-23T09:10:44Z","messageCount":1,"participants":["Han-Wen Nienhuys via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"422734","messageId":"pull.1010.git.git.1619169039954.gitgitgadget@gmail.com","threadId":"55544","inReplyTo":null,"subject":"[PATCH] refs/debug: trace into reflog expiry too","fromName":"Han-Wen Nienhuys via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-04-23T09:10:39Z","receivedAt":"2021-04-23T09:10:44Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"From: Han-Wen Nienhuys <hanwen@google.com>\n\nSigned-off-by: Han-Wen Nienhuys <hanwen@google.com>\n---\n    refs/debug: trace into reflog expiry too\n    \n    this is split out from my larger reftable series. It improves debug\n    output, so it's both not crucial to the reftable series, and should be\n    uncontroversial to merge into next.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1010%2Fhanwen%2Fdebug-expiry-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1010/hanwen/debug-expiry-v1\nPull-Request: https://github.com/git/git/pull/1010\n\n refs/debug.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 44 insertions(+), 3 deletions(-)\n\ndiff --git a/refs/debug.c b/refs/debug.c\nindex 922e64fa6ad9..3b25e3aeb1ba 100644\n--- a/refs/debug.c\n+++ b/refs/debug.c\n@@ -353,6 +353,40 @@ static int debug_delete_reflog(struct ref_store *ref_store, const char *refname)\n \treturn res;\n }\n \n+struct debug_reflog_expiry_should_prune {\n+\treflog_expiry_prepare_fn *prepare;\n+\treflog_expiry_should_prune_fn *should_prune;\n+\treflog_expiry_cleanup_fn *cleanup;\n+\tvoid *cb_data;\n+};\n+\n+static void debug_reflog_expiry_prepare(const char *refname,\n+\t\t\t\t    const struct object_id *oid,\n+\t\t\t\t    void *cb_data)\n+{\n+\tstruct debug_reflog_expiry_should_prune *prune = cb_data;\n+\ttrace_printf_key(&trace_refs, \"reflog_expire_prepare: %s\\n\", refname);\n+\tprune->prepare(refname, oid, prune->cb_data);\n+}\n+\n+static int debug_reflog_expiry_should_prune_fn(struct object_id *ooid,\n+\t\t\t\t\t       struct object_id *noid,\n+\t\t\t\t\t       const char *email,\n+\t\t\t\t\t       timestamp_t timestamp, int tz,\n+\t\t\t\t\t       const char *message, void *cb_data) {\n+\tstruct debug_reflog_expiry_should_prune *prune = cb_data;\n+\n+\tint result = prune->should_prune(ooid, noid, email, timestamp, tz, message, prune->cb_data);\n+\ttrace_printf_key(&trace_refs, \"reflog_expire_should_prune: %s %ld: %d\\n\", message, (long int) timestamp, result);\n+\treturn result;\n+}\n+\n+static void debug_reflog_expiry_cleanup(void *cb_data)\n+{\n+\tstruct debug_reflog_expiry_should_prune *prune = cb_data;\n+\tprune->cleanup(prune->cb_data);\n+}\n+\n static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,\n \t\t\t       const struct object_id *oid, unsigned int flags,\n \t\t\t       reflog_expiry_prepare_fn prepare_fn,\n@@ -361,10 +395,17 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,\n \t\t\t       void *policy_cb_data)\n {\n \tstruct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;\n+\tstruct debug_reflog_expiry_should_prune prune = {\n+\t\t.prepare = prepare_fn,\n+\t\t.cleanup = cleanup_fn,\n+\t\t.should_prune = should_prune_fn,\n+\t\t.cb_data = policy_cb_data,\n+\t};\n \tint res = drefs->refs->be->reflog_expire(drefs->refs, refname, oid,\n-\t\t\t\t\t\t flags, prepare_fn,\n-\t\t\t\t\t\t should_prune_fn, cleanup_fn,\n-\t\t\t\t\t\t policy_cb_data);\n+\t\t\t\t\t\t flags, &debug_reflog_expiry_prepare,\n+\t\t\t\t\t\t &debug_reflog_expiry_should_prune_fn,\n+\t\t\t\t\t\t &debug_reflog_expiry_cleanup,\n+\t\t\t\t\t\t &prune);\n \ttrace_printf_key(&trace_refs, \"reflog_expire: %s: %d\\n\", refname, res);\n \treturn res;\n }\n\nbase-commit: 311531c9de557d25ac087c1637818bd2aad6eb3a\n-- \ngitgitgadget\n"}]}