Adjust to git_buf and oid->id changes
This commit is contained in:
@@ -123,7 +123,7 @@ geef_commit_create(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
||||
i++;
|
||||
}
|
||||
|
||||
if (git_commit_create_from_oids(&commit_id, repo->repo, ref, author, committer, encoding, message,
|
||||
if (git_commit_create_from_ids(&commit_id, repo->repo, ref, author, committer, encoding, message,
|
||||
&tree, parents_len, parents_ids_ptrs) < 0)
|
||||
return geef_error(env);
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ geef_index_add(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
||||
if (!enif_inspect_binary(env, eentry[9], &id))
|
||||
return enif_make_badarg(env);
|
||||
|
||||
git_oid_fromraw(&entry.oid, id.data);
|
||||
git_oid_fromraw(&entry.id, id.data);
|
||||
|
||||
if (git_index_add(index->index, &entry) < 0)
|
||||
return geef_error(env);
|
||||
@@ -189,7 +189,7 @@ ERL_NIF_TERM entry_to_term(ErlNifEnv *env, const git_index_entry *entry)
|
||||
ErlNifBinary id, path;
|
||||
size_t len;
|
||||
|
||||
if (geef_oid_bin(&id, &entry->oid) < 0)
|
||||
if (geef_oid_bin(&id, &entry->id) < 0)
|
||||
return geef_oom(env);
|
||||
|
||||
len = strlen(entry->path);
|
||||
|
||||
@@ -73,6 +73,7 @@ geef_repository_open(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
||||
ERL_NIF_TERM
|
||||
geef_repository_discover(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
||||
{
|
||||
git_buf buf = {NULL};
|
||||
ErlNifBinary bin, path;
|
||||
int error;
|
||||
|
||||
@@ -82,21 +83,15 @@ geef_repository_discover(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
||||
if (!geef_terminate_binary(&bin))
|
||||
return geef_oom(env);
|
||||
|
||||
if (!enif_alloc_binary(256, &path))
|
||||
return geef_oom(env);
|
||||
|
||||
while ((error = git_repository_discover((char *) path.data, path.size,(char *) bin.data, 0, NULL)) < 0 &&
|
||||
giterr_last()->klass == GITERR_REPOSITORY) {
|
||||
if (!enif_realloc_binary(&path, path.size * 2))
|
||||
return geef_oom(env);
|
||||
}
|
||||
|
||||
if (error < 0) {
|
||||
enif_release_binary(&path);
|
||||
error = git_repository_discover(&buf, (char *) bin.data, 0, NULL);
|
||||
enif_release_binary(&bin);
|
||||
if (error < 0)
|
||||
return geef_error(env);
|
||||
}
|
||||
|
||||
enif_realloc_binary(&path, strlen((char *) path.data));
|
||||
if (!enif_alloc_binary(&path, strlen(buf.ptr)))
|
||||
return geef_oom(env);
|
||||
|
||||
memcpy(path.data, buf.ptr, path.size);
|
||||
|
||||
return enif_make_tuple2(env, atoms.ok, enif_make_binary(env, &path));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user