diff options
author | Russell Belfer <rb@github.com> | 2014-04-29 22:29:49 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-02 20:21:33 +0400 |
commit | b23b112dfe8eceb39eaaea2d5e60d971c4371aa0 (patch) | |
tree | 56a6c981856e5f1bf830c3b647a8a58838b044f5 /tests/diff/workdir.c | |
parent | 225aab5d6a611076b22f00ae5a28184d92b5259c (diff) |
Add payloads, bitmaps to trace API
This is a proposed adjustment to the trace APIs. This makes the
trace levels into a bitmask so that they can be selectively enabled
and adds a callback-level payload, plus a message-level payload.
This makes it easier for me to a GIT_TRACE_PERF callbacks that
are simply bypassed if the PERF level is not set.
Diffstat (limited to 'tests/diff/workdir.c')
-rw-r--r-- | tests/diff/workdir.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c index 0fd41d3e0..952c9022b 100644 --- a/tests/diff/workdir.c +++ b/tests/diff/workdir.c @@ -1,40 +1,19 @@ #include "clar_libgit2.h" #include "diff_helpers.h" #include "repository.h" -#include <git2/trace.h> static git_repository *g_repo = NULL; #ifdef GIT_TRACE -static struct { - size_t stat_calls; - size_t oid_calcs; - size_t submodule_lookups; -} g_diff_perf; - -static void add_stats(git_trace_level_t level, const char *msg) -{ - const char *assign = strchr(msg, '='); - - GIT_UNUSED(level); - - if (!assign) - return; - - if (!strncmp("stat", msg, (assign - msg))) - g_diff_perf.stat_calls += atoi(assign + 1); - else if (!strncmp("submodule_lookup", msg, (assign - msg))) - g_diff_perf.submodule_lookups += atoi(assign + 1); - else if (!strncmp("oid_calculation", msg, (assign - msg))) - g_diff_perf.oid_calcs += atoi(assign + 1); -} +static diff_perf g_diff_perf; #endif void test_diff_workdir__initialize(void) { #ifdef GIT_TRACE memset(&g_diff_perf, 0, sizeof(g_diff_perf)); - cl_git_pass(git_trace_set(GIT_TRACE_TRACE, add_stats)); + cl_git_pass(git_trace_set( + GIT_TRACE_PERF, diff_perf_track_stats, &g_diff_perf)); #endif } @@ -42,7 +21,7 @@ void test_diff_workdir__cleanup(void) { cl_git_sandbox_cleanup(); #ifdef GIT_TRACE - cl_git_pass(git_trace_set(0, NULL)); + cl_git_pass(git_trace_set(GIT_TRACE_NONE, NULL, NULL)); #endif } |