Add method to get the compiled version of the lib
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/include/git2/common.h b/include/git2/common.h
index ba54ce4..58cb1f2 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -113,6 +113,16 @@ typedef struct {
GIT_EXTERN(void) git_strarray_free(git_strarray *array);
+/**
+ * Return the version of the libgit2 library
+ * being currently used.
+ *
+ * @param major Store the major version number
+ * @param minor Store the minor version number
+ * @param rev Store the revision (patch) number
+ */
+GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/src/util.c b/src/util.c
index 560c40d..f36cce5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1,9 +1,17 @@
#define GIT__NO_HIDE_MALLOC
+#include <git2.h>
#include "common.h"
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
+void git_libgit2_version(int *major, int *minor, int *rev)
+{
+ *major = LIBGIT2_VER_MAJOR;
+ *minor = LIBGIT2_VER_MINOR;
+ *rev = LIBGIT2_VER_REVISION;
+}
+
void git_strarray_free(git_strarray *array)
{
size_t i;