50 lines
1.8 KiB
Diff
50 lines
1.8 KiB
Diff
From 668f5d07eef16e227402eab09141c738b315d94b Mon Sep 17 00:00:00 2001
|
|
From: Colomban Wendling <ban@herbesfolles.org>
|
|
Date: Sun, 5 Jun 2022 23:11:20 +0200
|
|
Subject: [PATCH 1/2] git-changebar: Simplify libgit2 version checks
|
|
|
|
Introduce a custom macro for libgit2 version checks for them to be both
|
|
easier to read and write.
|
|
---
|
|
git-changebar/src/gcb-plugin.c | 14 +++++++++++---
|
|
1 file changed, 11 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/git-changebar/src/gcb-plugin.c b/git-changebar/src/gcb-plugin.c
|
|
index f8ce20cd..bee8c865 100644
|
|
--- a/git-changebar/src/gcb-plugin.c
|
|
+++ b/git-changebar/src/gcb-plugin.c
|
|
@@ -32,11 +32,19 @@
|
|
#include <geany.h>
|
|
#include <document.h>
|
|
|
|
-#if ! defined (LIBGIT2_VER_MINOR) || ( (LIBGIT2_VER_MAJOR == 0) && (LIBGIT2_VER_MINOR < 22) )
|
|
+#ifdef LIBGIT2_VER_MINOR
|
|
+# define CHECK_LIBGIT2_VERSION(MAJOR, MINOR) \
|
|
+ ((LIBGIT2_VER_MAJOR == (MAJOR) && LIBGIT2_VER_MINOR >= (MINOR)) || \
|
|
+ LIBGIT2_VER_MAJOR > (MAJOR))
|
|
+#else /* ! defined(LIBGIT2_VER_MINOR) */
|
|
+# define CHECK_LIBGIT2_VERSION(MAJOR, MINOR) 0
|
|
+#endif
|
|
+
|
|
+#if ! CHECK_LIBGIT2_VERSION(0, 22)
|
|
# define git_libgit2_init git_threads_init
|
|
# define git_libgit2_shutdown git_threads_shutdown
|
|
#endif
|
|
-#if ! defined (LIBGIT2_VER_MINOR) || ( (LIBGIT2_VER_MAJOR == 0) && (LIBGIT2_VER_MINOR < 23) )
|
|
+#if ! CHECK_LIBGIT2_VERSION(0, 23)
|
|
/* 0.23 added @p binary_cb */
|
|
# define git_diff_buffers(old_buffer, old_len, old_as_path, \
|
|
new_buffer, new_len, new_as_path, options, \
|
|
@@ -45,7 +53,7 @@
|
|
new_buffer, new_len, new_as_path, options, \
|
|
file_cb, hunk_cb, line_cb, payload)
|
|
#endif
|
|
-#if ! defined (LIBGIT2_VER_MINOR) || ( (LIBGIT2_VER_MAJOR == 0) && (LIBGIT2_VER_MINOR < 28) )
|
|
+#if ! CHECK_LIBGIT2_VERSION(0, 28)
|
|
# define git_buf_dispose git_buf_free
|
|
# define git_error_last giterr_last
|
|
#endif
|
|
--
|
|
2.38.0
|
|
|