Adjust to libgit2 dup changes

This commit is contained in:
Carlos Martín Nieto
2014-01-19 01:27:26 +01:00
parent 60b4cb537a
commit 7a606b9b1c
4 changed files with 26 additions and 21 deletions

View File

@@ -69,14 +69,20 @@ wrap_blame_hunk(const git_blame_hunk *hunk, Blame *blame)
py_hunk->lines_in_hunk = hunk->lines_in_hunk;
py_hunk->final_commit_id = git_oid_allocfmt(&hunk->final_commit_id);
py_hunk->final_start_line_number = hunk->final_start_line_number;
py_hunk->final_signature = hunk->final_signature != NULL ?
git_signature_dup(hunk->final_signature) : NULL;
py_hunk->final_signature = NULL;
if (hunk->final_signature)
git_signature_dup(&py_hunk->final_signature, hunk->final_signature);
py_hunk->orig_commit_id = git_oid_allocfmt(&hunk->orig_commit_id);
py_hunk->orig_path = hunk->orig_path != NULL ?
strdup(hunk->orig_path) : NULL;
py_hunk->orig_start_line_number = hunk->orig_start_line_number;
py_hunk->orig_signature = hunk->orig_signature != NULL ?
git_signature_dup(hunk->orig_signature) : NULL;
py_hunk->orig_signature = NULL;
if (hunk->orig_signature)
git_signature_dup(&py_hunk->orig_signature, hunk->orig_signature);
py_hunk->boundary = hunk->boundary;
}

View File

@@ -62,8 +62,7 @@ RefLogIter_iternext(RefLogIter *self)
py_entry->oid_old = git_oid_allocfmt(git_reflog_entry_id_old(entry));
py_entry->oid_new = git_oid_allocfmt(git_reflog_entry_id_new(entry));
py_entry->message = strdup(git_reflog_entry_message(entry));
py_entry->signature = git_signature_dup(
git_reflog_entry_committer(entry));
git_signature_dup(&py_entry->signature, git_reflog_entry_committer(entry));
++(self->i);

View File

@@ -284,20 +284,20 @@ TreeEntry *
Tree_getitem_by_index(Tree *self, PyObject *py_index)
{
int index;
const git_tree_entry *entry;
const git_tree_entry *entry_src;
git_tree_entry *entry;
index = Tree_fix_index(self, py_index);
if (PyErr_Occurred())
return NULL;
entry = git_tree_entry_byindex(self->tree, index);
if (!entry) {
entry_src = git_tree_entry_byindex(self->tree, index);
if (!entry_src) {
PyErr_SetObject(PyExc_IndexError, py_index);
return NULL;
}
entry = git_tree_entry_dup(entry);
if (entry == NULL) {
if (git_tree_entry_dup(&entry, entry_src) < 0) {
PyErr_SetNone(PyExc_MemoryError);
return NULL;
}
@@ -550,16 +550,16 @@ TreeIter_dealloc(TreeIter *self)
TreeEntry *
TreeIter_iternext(TreeIter *self)
{
const git_tree_entry *entry;
const git_tree_entry *entry_src;
git_tree_entry *entry;
entry = git_tree_entry_byindex(self->owner->tree, self->i);
if (!entry)
entry_src = git_tree_entry_byindex(self->owner->tree, self->i);
if (!entry_src)
return NULL;
self->i += 1;
entry = git_tree_entry_dup(entry);
if (entry == NULL) {
if (git_tree_entry_dup(&entry, entry_src) < 0) {
PyErr_SetNone(PyExc_MemoryError);
return NULL;
}

View File

@@ -105,19 +105,19 @@ PyObject *
TreeBuilder_get(TreeBuilder *self, PyObject *py_filename)
{
char *filename;
const git_tree_entry *entry;
const git_tree_entry *entry_src;
git_tree_entry *entry;
filename = py_path_to_c_str(py_filename);
if (filename == NULL)
return NULL;
entry = git_treebuilder_get(self->bld, filename);
entry_src = git_treebuilder_get(self->bld, filename);
free(filename);
if (entry == NULL)
if (entry_src == NULL)
Py_RETURN_NONE;
entry = git_tree_entry_dup(entry);
if (entry == NULL) {
if (git_tree_entry_dup(&entry, entry_src) < 0) {
PyErr_SetNone(PyExc_MemoryError);
return NULL;
}