Commit 8507bf81ea5cf11a99566f449e6b3af68bd02430

Edward Thomson 2021-09-26T21:54:08

trace: always enabled There's no need to make tracing opt-in; it should always be included.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 229ba96..cab0cb2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,6 @@ OPTION(THREADSAFE			"Build libgit2 as threadsafe"				 ON)
 OPTION(BUILD_TESTS			"Build Tests using the Clar suite"			 ON)
 OPTION(BUILD_EXAMPLES			"Build library usage example apps"			OFF)
 OPTION(BUILD_FUZZERS			"Build the fuzz targets"				OFF)
-OPTION(ENABLE_TRACE			"Enables tracing support"				ON)
 OPTION(LIBGIT2_FILENAME			"Name of the produced binary"				OFF)
 OPTION(USE_SSH				"Link with libssh2 to enable SSH support"		 ON)
 OPTION(USE_HTTPS			"Enable HTTPS support. Can be set to a specific backend" ON)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fdb3673..b3d620c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -37,12 +37,6 @@ SET(LIBGIT2_LIBS "")
 
 enable_warnings(missing-declarations)
 
-# Enable tracing
-IF(ENABLE_TRACE)
-	SET(GIT_TRACE 1)
-ENDIF()
-ADD_FEATURE_INFO(tracing GIT_TRACE "tracing support")
-
 IF (HAVE_FUTIMENS)
 	SET(GIT_USE_FUTIMENS 1)
 ENDIF ()
diff --git a/src/features.h.in b/src/features.h.in
index 202cef4..a40b608 100644
--- a/src/features.h.in
+++ b/src/features.h.in
@@ -5,7 +5,6 @@
 #cmakedefine GIT_DEBUG_STRICT_ALLOC 1
 #cmakedefine GIT_DEBUG_STRICT_OPEN 1
 
-#cmakedefine GIT_TRACE 1
 #cmakedefine GIT_THREADS 1
 #cmakedefine GIT_WIN32_LEAKCHECK 1
 
diff --git a/src/trace.c b/src/trace.c
index c316bca..b0c56c4 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -11,15 +11,10 @@
 #include "runtime.h"
 #include "git2/trace.h"
 
-#ifdef GIT_TRACE
-
 struct git_trace_data git_trace__data = {0};
 
-#endif
-
 int git_trace_set(git_trace_level_t level, git_trace_cb callback)
 {
-#ifdef GIT_TRACE
 	GIT_ASSERT_ARG(level == 0 || callback != NULL);
 
 	git_trace__data.level = level;
@@ -27,12 +22,4 @@ int git_trace_set(git_trace_level_t level, git_trace_cb callback)
 	GIT_MEMORY_BARRIER;
 
 	return 0;
-#else
-	GIT_UNUSED(level);
-	GIT_UNUSED(callback);
-
-	git_error_set(GIT_ERROR_INVALID,
-		"this version of libgit2 was not built with tracing.");
-	return -1;
-#endif
 }
diff --git a/src/trace.h b/src/trace.h
index eb20ec5..239928d 100644
--- a/src/trace.h
+++ b/src/trace.h
@@ -12,8 +12,6 @@
 #include <git2/trace.h>
 #include "str.h"
 
-#ifdef GIT_TRACE
-
 struct git_trace_data {
 	git_trace_level_t level;
 	git_trace_cb callback;
@@ -50,19 +48,4 @@ GIT_INLINE(void) git_trace(git_trace_level_t level, const char *fmt, ...)
 	}
 }
 
-#else
-
-GIT_INLINE(void) git_trace__null(
-	git_trace_level_t level,
-	const char *fmt, ...)
-{
-	GIT_UNUSED(level);
-	GIT_UNUSED(fmt);
-}
-
-#define git_trace_level()	((git_trace_level_t)0)
-#define git_trace		git_trace__null
-
-#endif
-
 #endif