Expose git_libgit2_version
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include "commit.h"
|
#include "commit.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "blob.h"
|
#include "blob.h"
|
||||||
|
#include "library.h"
|
||||||
#include "geef.h"
|
#include "geef.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -112,6 +113,7 @@ static ErlNifFunc geef_funcs[] =
|
|||||||
{"tree_bypath", 2, geef_tree_bypath},
|
{"tree_bypath", 2, geef_tree_bypath},
|
||||||
{"blob_size", 1, geef_blob_size},
|
{"blob_size", 1, geef_blob_size},
|
||||||
{"blob_content", 1, geef_blob_content},
|
{"blob_content", 1, geef_blob_content},
|
||||||
|
{"library_version", 0, geef_library_version},
|
||||||
};
|
};
|
||||||
|
|
||||||
ERL_NIF_INIT(geef, geef_funcs, load, NULL, upgrade, unload)
|
ERL_NIF_INIT(geef, geef_funcs, load, NULL, upgrade, unload)
|
||||||
|
|||||||
11
c_src/library.c
Normal file
11
c_src/library.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "erl_nif.h"
|
||||||
|
#include <git2.h>
|
||||||
|
|
||||||
|
ERL_NIF_TERM geef_library_version(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
||||||
|
{
|
||||||
|
int major, minor, rev;
|
||||||
|
|
||||||
|
git_libgit2_version(&major, &minor, &rev);
|
||||||
|
|
||||||
|
return enif_make_tuple3(env, enif_make_int(env, major), enif_make_int(env, minor), enif_make_int(env, rev));
|
||||||
|
}
|
||||||
6
c_src/library.h
Normal file
6
c_src/library.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef GEEF_LIBRARY_H
|
||||||
|
#define GEEF_LIBRARY_H
|
||||||
|
|
||||||
|
ERL_NIF_TERM geef_library_version(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
% objects
|
% objects
|
||||||
-export([object_lookup/2, object_id/1, commit_tree_id/1, commit_tree/1, tree_bypath/2, blob_size/1, blob_content/1]).
|
-export([object_lookup/2, object_id/1, commit_tree_id/1, commit_tree/1, tree_bypath/2, blob_size/1, blob_content/1]).
|
||||||
|
|
||||||
|
% git_libgit2
|
||||||
|
-export([library_version/0]).
|
||||||
|
|
||||||
-on_load(load_enif/0).
|
-on_load(load_enif/0).
|
||||||
|
|
||||||
hex_to_raw(_Val) ->
|
hex_to_raw(_Val) ->
|
||||||
@@ -108,6 +111,10 @@ blob_size(_ObjHandle) ->
|
|||||||
blob_content(_ObjHandle) ->
|
blob_content(_ObjHandle) ->
|
||||||
nif_error(?LINE).
|
nif_error(?LINE).
|
||||||
|
|
||||||
|
-spec library_version() -> {integer, integer, integer}.
|
||||||
|
library_version() ->
|
||||||
|
nif_error(?LINE).
|
||||||
|
|
||||||
nif_error(Line) ->
|
nif_error(Line) ->
|
||||||
erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).
|
erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user