fixex api changes of libgit2 in 64c5112
This commit is contained in:
parent
0406841533
commit
a511f299bb
include/pygit2
src/pygit2
test
@ -97,7 +97,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
git_index_entry *entry;
|
const git_index_entry *entry;
|
||||||
} IndexEntry;
|
} IndexEntry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -135,7 +135,7 @@ Commit_get_parents(Commit *commit)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i=0; i < parent_count; i++) {
|
for (i=0; i < parent_count; i++) {
|
||||||
parent_oid = git_commit_parent_oid(commit->commit, i);
|
parent_oid = git_commit_parent_id(commit->commit, i);
|
||||||
if (parent_oid == NULL) {
|
if (parent_oid == NULL) {
|
||||||
Py_DECREF(list);
|
Py_DECREF(list);
|
||||||
Error_set(GIT_ENOTFOUND);
|
Error_set(GIT_ENOTFOUND);
|
||||||
|
@ -204,7 +204,7 @@ Config_setitem(Config *self, PyObject *py_key, PyObject *py_value)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!py_value) {
|
if (!py_value) {
|
||||||
err = git_config_delete(self->config, c_key);
|
err = git_config_delete_entry(self->config, c_key);
|
||||||
} else if (PyBool_Check(py_value)) {
|
} else if (PyBool_Check(py_value)) {
|
||||||
err = git_config_set_bool(self->config, c_key,
|
err = git_config_set_bool(self->config, c_key,
|
||||||
(int)PyObject_IsTrue(py_value));
|
(int)PyObject_IsTrue(py_value));
|
||||||
|
@ -41,12 +41,12 @@ extern PyTypeObject DiffType;
|
|||||||
extern PyTypeObject HunkType;
|
extern PyTypeObject HunkType;
|
||||||
|
|
||||||
static int diff_data_cb(
|
static int diff_data_cb(
|
||||||
void *cb_data,
|
|
||||||
const git_diff_delta *delta,
|
const git_diff_delta *delta,
|
||||||
const git_diff_range *range,
|
const git_diff_range *range,
|
||||||
char line_origin,
|
char line_origin,
|
||||||
const char *content,
|
const char *content,
|
||||||
size_t content_len)
|
size_t content_len,
|
||||||
|
void *cb_data)
|
||||||
{
|
{
|
||||||
PyObject *hunks, *data;
|
PyObject *hunks, *data;
|
||||||
Hunk *hunk;
|
Hunk *hunk;
|
||||||
@ -72,11 +72,11 @@ static int diff_data_cb(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int diff_hunk_cb(
|
static int diff_hunk_cb(
|
||||||
void *cb_data,
|
|
||||||
const git_diff_delta *delta,
|
const git_diff_delta *delta,
|
||||||
const git_diff_range *range,
|
const git_diff_range *range,
|
||||||
const char *header,
|
const char *header,
|
||||||
size_t header_len)
|
size_t header_len,
|
||||||
|
void *cb_data)
|
||||||
{
|
{
|
||||||
PyObject *hunks;
|
PyObject *hunks;
|
||||||
Hunk *hunk;
|
Hunk *hunk;
|
||||||
@ -163,8 +163,8 @@ static int diff_hunk_cb(
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int diff_file_cb(void *cb_data, const git_diff_delta *delta,
|
static int diff_file_cb(const git_diff_delta *delta, float progress,
|
||||||
float progress)
|
void *cb_data)
|
||||||
{
|
{
|
||||||
PyObject *files, *file;
|
PyObject *files, *file;
|
||||||
|
|
||||||
@ -202,10 +202,10 @@ Diff_changes(Diff *self)
|
|||||||
|
|
||||||
git_diff_foreach(
|
git_diff_foreach(
|
||||||
self->diff,
|
self->diff,
|
||||||
self->diff_changes,
|
|
||||||
&diff_file_cb,
|
&diff_file_cb,
|
||||||
&diff_hunk_cb,
|
&diff_hunk_cb,
|
||||||
&diff_data_cb
|
&diff_data_cb,
|
||||||
|
self->diff_changes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,12 +213,12 @@ Diff_changes(Diff *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int diff_print_cb(
|
static int diff_print_cb(
|
||||||
void *cb_data,
|
|
||||||
const git_diff_delta *delta,
|
const git_diff_delta *delta,
|
||||||
const git_diff_range *range,
|
const git_diff_range *range,
|
||||||
char usage,
|
char usage,
|
||||||
const char *line,
|
const char *line,
|
||||||
size_t line_len)
|
size_t line_len,
|
||||||
|
void *cb_data)
|
||||||
{
|
{
|
||||||
PyObject *data = PyBytes_FromStringAndSize(line, line_len);
|
PyObject *data = PyBytes_FromStringAndSize(line, line_len);
|
||||||
PyBytes_ConcatAndDel((PyObject **)cb_data, data);
|
PyBytes_ConcatAndDel((PyObject **)cb_data, data);
|
||||||
@ -231,7 +231,7 @@ Diff_patch(Diff *self)
|
|||||||
{
|
{
|
||||||
PyObject *patch = PyBytes_FromString("");
|
PyObject *patch = PyBytes_FromString("");
|
||||||
|
|
||||||
git_diff_print_patch(self->diff, &patch, &diff_print_cb);
|
git_diff_print_patch(self->diff, &diff_print_cb, (void*) &patch);
|
||||||
|
|
||||||
return patch;
|
return patch;
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ PyObject *
|
|||||||
Diff_find_similar(Diff *self, PyObject *args)
|
Diff_find_similar(Diff *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
git_diff_options opts = {0};
|
git_diff_find_options opts = {0};
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|i", &opts.flags))
|
if (!PyArg_ParseTuple(args, "|i", &opts.flags))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -264,7 +264,7 @@ Index_len(Index *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
wrap_index_entry(git_index_entry *entry, Index *index)
|
wrap_index_entry(const git_index_entry *entry, Index *index)
|
||||||
{
|
{
|
||||||
IndexEntry *py_entry;
|
IndexEntry *py_entry;
|
||||||
|
|
||||||
@ -278,8 +278,8 @@ wrap_index_entry(git_index_entry *entry, Index *index)
|
|||||||
PyObject *
|
PyObject *
|
||||||
Index_getitem(Index *self, PyObject *value)
|
Index_getitem(Index *self, PyObject *value)
|
||||||
{
|
{
|
||||||
int idx;
|
size_t idx;
|
||||||
git_index_entry *index_entry;
|
const git_index_entry *index_entry;
|
||||||
|
|
||||||
idx = Index_get_position(self, value);
|
idx = Index_get_position(self, value);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
@ -460,7 +460,7 @@ IndexIter_dealloc(IndexIter *self)
|
|||||||
PyObject *
|
PyObject *
|
||||||
IndexIter_iternext(IndexIter *self)
|
IndexIter_iternext(IndexIter *self)
|
||||||
{
|
{
|
||||||
git_index_entry *index_entry;
|
const git_index_entry *index_entry;
|
||||||
|
|
||||||
index_entry = git_index_get_byindex(self->owner->index, self->i);
|
index_entry = git_index_get_byindex(self->owner->index, self->i);
|
||||||
if (!index_entry)
|
if (!index_entry)
|
||||||
|
@ -63,13 +63,13 @@ PyObject* RefLogIter_iternext(PyObject *self)
|
|||||||
&RefLogEntryType, NULL, NULL
|
&RefLogEntryType, NULL, NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
git_oid_fmt(oid_old, git_reflog_entry_oidold(entry));
|
git_oid_fmt(oid_old, git_reflog_entry_id_old(entry));
|
||||||
git_oid_fmt(oid_new, git_reflog_entry_oidnew(entry));
|
git_oid_fmt(oid_new, git_reflog_entry_id_new(entry));
|
||||||
|
|
||||||
py_entry->oid_new = PyUnicode_FromStringAndSize(oid_new, 40);
|
py_entry->oid_new = PyUnicode_FromStringAndSize(oid_new, 40);
|
||||||
py_entry->oid_old = PyUnicode_FromStringAndSize(oid_old, 40);
|
py_entry->oid_old = PyUnicode_FromStringAndSize(oid_old, 40);
|
||||||
|
|
||||||
py_entry->msg = strdup(git_reflog_entry_msg(entry));
|
py_entry->msg = strdup(git_reflog_entry_message(entry));
|
||||||
|
|
||||||
signature = git_signature_dup(
|
signature = git_signature_dup(
|
||||||
git_reflog_entry_committer(entry)
|
git_reflog_entry_committer(entry)
|
||||||
@ -220,10 +220,14 @@ Reference_get_target(Reference *self)
|
|||||||
CHECK_REFERENCE(self);
|
CHECK_REFERENCE(self);
|
||||||
|
|
||||||
/* Get the target */
|
/* Get the target */
|
||||||
c_name = git_reference_target(self->reference);
|
if (GIT_REF_OID == git_reference_type(self->reference)) {
|
||||||
if (c_name == NULL) {
|
return git_oid_to_py_str(git_reference_target(self->reference));
|
||||||
PyErr_SetString(PyExc_ValueError, "no target available");
|
} else {
|
||||||
return NULL;
|
c_name = git_reference_symbolic_target(self->reference);
|
||||||
|
if (c_name == NULL) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "no target available");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make a PyString and return it */
|
/* Make a PyString and return it */
|
||||||
@ -244,7 +248,7 @@ Reference_set_target(Reference *self, PyObject *py_name)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Set the new target */
|
/* Set the new target */
|
||||||
err = git_reference_set_target(self->reference, c_name);
|
err = git_reference_symbolic_set_target(self->reference, c_name);
|
||||||
free(c_name);
|
free(c_name);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
Error_set(err);
|
Error_set(err);
|
||||||
@ -269,7 +273,7 @@ Reference_get_oid(Reference *self)
|
|||||||
CHECK_REFERENCE(self);
|
CHECK_REFERENCE(self);
|
||||||
|
|
||||||
/* Get the oid (only for "direct" references) */
|
/* Get the oid (only for "direct" references) */
|
||||||
oid = git_reference_oid(self->reference);
|
oid = git_reference_target(self->reference);
|
||||||
if (oid == NULL) {
|
if (oid == NULL) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"oid is only available if the reference is direct "
|
"oid is only available if the reference is direct "
|
||||||
@ -297,7 +301,7 @@ Reference_set_oid(Reference *self, PyObject *py_hex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set the oid */
|
/* Set the oid */
|
||||||
err = git_reference_set_oid(self->reference, &oid);
|
err = git_reference_set_target(self->reference, &oid);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
Error_set(err);
|
Error_set(err);
|
||||||
return -1;
|
return -1;
|
||||||
@ -314,7 +318,7 @@ Reference_get_hex(Reference *self)
|
|||||||
CHECK_REFERENCE(self);
|
CHECK_REFERENCE(self);
|
||||||
|
|
||||||
/* Get the oid (only for "direct" references) */
|
/* Get the oid (only for "direct" references) */
|
||||||
oid = git_reference_oid(self->reference);
|
oid = git_reference_target(self->reference);
|
||||||
if (oid == NULL) {
|
if (oid == NULL) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"oid is only available if the reference is direct "
|
"oid is only available if the reference is direct "
|
||||||
|
@ -179,7 +179,7 @@ Repository_head(Repository *self)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
oid = git_reference_oid(head);
|
oid = git_reference_target(head);
|
||||||
pyobj = lookup_object(self, oid, GIT_OBJ_COMMIT);
|
pyobj = lookup_object(self, oid, GIT_OBJ_COMMIT);
|
||||||
git_reference_free(head);
|
git_reference_free(head);
|
||||||
return pyobj;
|
return pyobj;
|
||||||
@ -527,7 +527,7 @@ Repository_create_blob_fromfile(Repository *self, PyObject *args)
|
|||||||
if (!PyArg_ParseTuple(args, "s", &path))
|
if (!PyArg_ParseTuple(args, "s", &path))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
err = git_blob_create_fromfile(&oid, self->repo, path);
|
err = git_blob_create_fromworkdir(&oid, self->repo, path);
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return Error_set(err);
|
return Error_set(err);
|
||||||
@ -740,7 +740,7 @@ Repository_create_reference(Repository *self, PyObject *args, PyObject* keywds)
|
|||||||
return Error_set(err);
|
return Error_set(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = git_reference_create_oid(&c_reference, self->repo, c_name, &oid, force);
|
err = git_reference_create(&c_reference, self->repo, c_name, &oid, force);
|
||||||
} else {
|
} else {
|
||||||
#if PY_MAJOR_VERSION == 2
|
#if PY_MAJOR_VERSION == 2
|
||||||
c_target = PyString_AsString(py_obj);
|
c_target = PyString_AsString(py_obj);
|
||||||
@ -750,7 +750,7 @@ Repository_create_reference(Repository *self, PyObject *args, PyObject* keywds)
|
|||||||
if(c_target == NULL)
|
if(c_target == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
err = git_reference_create_symbolic(&c_reference, self->repo, c_name,
|
err = git_reference_symbolic_create(&c_reference, self->repo, c_name,
|
||||||
c_target, force);
|
c_target, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ Tag_get_target(Tag *self)
|
|||||||
{
|
{
|
||||||
const git_oid *oid;
|
const git_oid *oid;
|
||||||
|
|
||||||
oid = git_tag_target_oid(self->tag);
|
oid = git_tag_target_id(self->tag);
|
||||||
return git_oid_to_python(oid->id);
|
return git_oid_to_python(oid->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,6 +174,7 @@ class ReferencesTest(utils.RepoTestCase):
|
|||||||
self.assertTrue('refs/tags/version1' in refs)
|
self.assertTrue('refs/tags/version1' in refs)
|
||||||
reference = self.repo.lookup_reference('refs/tags/version1')
|
reference = self.repo.lookup_reference('refs/tags/version1')
|
||||||
self.assertEqual(reference.hex, LAST_COMMIT)
|
self.assertEqual(reference.hex, LAST_COMMIT)
|
||||||
|
self.assertEqual(reference.target, LAST_COMMIT)
|
||||||
|
|
||||||
# try to create existing reference
|
# try to create existing reference
|
||||||
self.assertRaises(ValueError, self.repo.create_reference,
|
self.assertRaises(ValueError, self.repo.create_reference,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user