Remove old object_exists
This commit is contained in:
27
c_src/geef.c
27
c_src/geef.c
@@ -29,32 +29,6 @@ geef_hex_to_raw(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
|||||||
return enif_make_binary(env, &ibin);
|
return enif_make_binary(env, &ibin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ERL_NIF_TERM
|
|
||||||
geef_object_exists(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
|
||||||
{
|
|
||||||
char path[MAXBUFLEN];
|
|
||||||
char sha[MAXBUFLEN];
|
|
||||||
(void)memset(&path, '\0', sizeof(path));
|
|
||||||
(void)memset(&sha, '\0', sizeof(sha));
|
|
||||||
|
|
||||||
if (enif_get_string(env, argv[0], path, sizeof(path), ERL_NIF_LATIN1) < 1)
|
|
||||||
return enif_make_badarg(env);
|
|
||||||
if (enif_get_string(env, argv[1], sha, sizeof(sha), ERL_NIF_LATIN1) < 1)
|
|
||||||
return enif_make_badarg(env);
|
|
||||||
|
|
||||||
git_odb *odb;
|
|
||||||
git_odb_open(&odb, path);
|
|
||||||
|
|
||||||
git_oid oid;
|
|
||||||
git_oid_fromstr(&oid, sha);
|
|
||||||
|
|
||||||
int exists = git_odb_exists(odb, &oid);
|
|
||||||
if(exists == 1) {
|
|
||||||
return enif_make_atom(env, "true");
|
|
||||||
}
|
|
||||||
return enif_make_atom(env, "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
static int load(ErlNifEnv *env, void **priv, ERL_NIF_TERM load_info)
|
static int load(ErlNifEnv *env, void **priv, ERL_NIF_TERM load_info)
|
||||||
{
|
{
|
||||||
geef_repository_type = enif_open_resource_type(env, NULL,
|
geef_repository_type = enif_open_resource_type(env, NULL,
|
||||||
@@ -96,7 +70,6 @@ geef_error(ErlNifEnv *env)
|
|||||||
static ErlNifFunc geef_funcs[] =
|
static ErlNifFunc geef_funcs[] =
|
||||||
{
|
{
|
||||||
{"hex_to_raw", 1, geef_hex_to_raw},
|
{"hex_to_raw", 1, geef_hex_to_raw},
|
||||||
{"object_exists", 2, geef_object_exists},
|
|
||||||
{"repository_open", 1, geef_repository_open},
|
{"repository_open", 1, geef_repository_open},
|
||||||
{"repository_get_path", 1, geef_repository_path},
|
{"repository_get_path", 1, geef_repository_path},
|
||||||
{"repository_get_odb", 1, geef_repository_odb},
|
{"repository_get_odb", 1, geef_repository_odb},
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
-module(geef).
|
-module(geef).
|
||||||
-export([hex_to_raw/1, object_exists/2, repository/1, repository_path/1, repository_odb/1, odb_exists/2]).
|
-export([hex_to_raw/1, repository/1, repository_path/1, repository_odb/1, odb_exists/2]).
|
||||||
-on_load(load_enif/0).
|
-on_load(load_enif/0).
|
||||||
|
|
||||||
hex_to_raw(_Val) ->
|
hex_to_raw(_Val) ->
|
||||||
nif_error(?LINE).
|
nif_error(?LINE).
|
||||||
|
|
||||||
object_exists(_Val, _Val2) ->
|
|
||||||
nif_error(?LINE).
|
|
||||||
|
|
||||||
repository_open(_Val) ->
|
repository_open(_Val) ->
|
||||||
nif_error(?LINE).
|
nif_error(?LINE).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user