Commit 225aab5d by Russell Belfer

Don't use trace if GIT_TRACE not defined

parent cd424ad5
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
static git_repository *g_repo = NULL; static git_repository *g_repo = NULL;
#ifdef GIT_TRACE
static struct { static struct {
size_t stat_calls; size_t stat_calls;
size_t oid_calcs; size_t oid_calcs;
...@@ -27,17 +28,22 @@ static void add_stats(git_trace_level_t level, const char *msg) ...@@ -27,17 +28,22 @@ static void add_stats(git_trace_level_t level, const char *msg)
else if (!strncmp("oid_calculation", msg, (assign - msg))) else if (!strncmp("oid_calculation", msg, (assign - msg)))
g_diff_perf.oid_calcs += atoi(assign + 1); g_diff_perf.oid_calcs += atoi(assign + 1);
} }
#endif
void test_diff_workdir__initialize(void) void test_diff_workdir__initialize(void)
{ {
#ifdef GIT_TRACE
memset(&g_diff_perf, 0, sizeof(g_diff_perf)); 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_TRACE, add_stats));
#endif
} }
void test_diff_workdir__cleanup(void) void test_diff_workdir__cleanup(void)
{ {
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
#ifdef GIT_TRACE
cl_git_pass(git_trace_set(0, NULL)); cl_git_pass(git_trace_set(0, NULL));
#endif
} }
void test_diff_workdir__to_index(void) void test_diff_workdir__to_index(void)
...@@ -1547,7 +1553,9 @@ static void basic_diff_status(git_diff **out, const git_diff_options *opts) ...@@ -1547,7 +1553,9 @@ static void basic_diff_status(git_diff **out, const git_diff_options *opts)
{ {
diff_expects exp; diff_expects exp;
#ifdef GIT_TRACE
memset(&g_diff_perf, 0, sizeof(g_diff_perf)); memset(&g_diff_perf, 0, sizeof(g_diff_perf));
#endif
cl_git_pass(git_diff_index_to_workdir(out, g_repo, NULL, opts)); cl_git_pass(git_diff_index_to_workdir(out, g_repo, NULL, opts));
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "path.h" #include "path.h"
#include <git2/trace.h> #include <git2/trace.h>
#ifdef GIT_TRACE
static struct { static struct {
size_t stat_calls; size_t stat_calls;
size_t oid_calcs; size_t oid_calcs;
...@@ -29,11 +30,14 @@ static void add_stats(git_trace_level_t level, const char *msg) ...@@ -29,11 +30,14 @@ static void add_stats(git_trace_level_t level, const char *msg)
else if (!strncmp("oid_calculation", msg, (assign - msg))) else if (!strncmp("oid_calculation", msg, (assign - msg)))
g_diff_perf.oid_calcs += atoi(assign + 1); g_diff_perf.oid_calcs += atoi(assign + 1);
} }
#endif
void test_status_worktree__initialize(void) void test_status_worktree__initialize(void)
{ {
#ifdef GIT_TRACE
memset(&g_diff_perf, 0, sizeof(g_diff_perf)); 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_TRACE, add_stats));
#endif
} }
/** /**
...@@ -45,7 +49,9 @@ void test_status_worktree__initialize(void) ...@@ -45,7 +49,9 @@ void test_status_worktree__initialize(void)
void test_status_worktree__cleanup(void) void test_status_worktree__cleanup(void)
{ {
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
#ifdef GIT_TRACE
cl_git_pass(git_trace_set(0, NULL)); cl_git_pass(git_trace_set(0, NULL));
#endif
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment