Add geef_commit:tree_id
This commit is contained in:
24
c_src/commit.c
Normal file
24
c_src/commit.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "geef.h"
|
||||
#include "repository.h"
|
||||
#include "object.h"
|
||||
#include "oid.h"
|
||||
#include <string.h>
|
||||
#include <git2.h>
|
||||
|
||||
ERL_NIF_TERM
|
||||
geef_commit_tree_id(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
||||
{
|
||||
const git_oid *id;
|
||||
geef_object *obj;
|
||||
ErlNifBinary bin;
|
||||
|
||||
if (!enif_get_resource(env, argv[0], geef_object_type, (void **) &obj))
|
||||
return enif_make_badarg(env);
|
||||
|
||||
id = git_commit_tree_id((git_commit *) obj->obj);
|
||||
|
||||
if (geef_oid_bin(&bin, id) < 0)
|
||||
return atoms.error;
|
||||
|
||||
return enif_make_binary(env, &bin);
|
||||
}
|
||||
6
c_src/commit.h
Normal file
6
c_src/commit.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef GEEF_COMMIT_H
|
||||
#define GEEF_COMMIT_H
|
||||
|
||||
ERL_NIF_TERM geef_commit_tree_id(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]);
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "reference.h"
|
||||
#include "oid.h"
|
||||
#include "object.h"
|
||||
#include "commit.h"
|
||||
#include "geef.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -97,6 +98,7 @@ static ErlNifFunc geef_funcs[] =
|
||||
{"oid_fmt", 1, geef_oid_fmt},
|
||||
{"oid_parse", 1, geef_oid_parse},
|
||||
{"object_lookup", 2, geef_object_lookup},
|
||||
{"commit_tree_id", 1, geef_commit_tree_id},
|
||||
};
|
||||
|
||||
ERL_NIF_INIT(geef, geef_funcs, load, NULL, NULL, unload)
|
||||
|
||||
Reference in New Issue
Block a user