Make pygit2 build against new libgit2 API

- Replace git_person with git_signature
- Replace include directives with git2
This commit is contained in:
Rui Abreu Ferreira
2011-01-07 15:21:47 +00:00
committed by Rui Abreu Ferreira
parent 58a439467f
commit 9e919c3966

View File

@@ -26,13 +26,8 @@
*/ */
#include <Python.h> #include <Python.h>
#include <git/commit.h> #include <git2.h>
#include <git/common.h>
#include <git/errors.h>
#include <git/repository.h>
#include <git/commit.h>
#include <git/odb.h>
#include <git/tag.h>
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
@@ -559,11 +554,11 @@ Commit_get_commit_time(Commit *commit) {
static PyObject * static PyObject *
Commit_get_committer(Commit *commit) { Commit_get_committer(Commit *commit) {
git_person *committer; const git_signature *committer = git_commit_committer(commit->commit);
committer = (git_person*)git_commit_committer(commit->commit);
return build_person(git_person_name(committer), return build_person(committer->name,
git_person_email(committer), committer->email,
git_person_time(committer)); committer->when.time);
} }
static int static int
@@ -572,17 +567,22 @@ Commit_set_committer(Commit *commit, PyObject *value) {
long long time; long long time;
if (!parse_person(value, &name, &email, &time)) if (!parse_person(value, &name, &email, &time))
return -1; return -1;
git_commit_set_committer(commit->commit, name, email, time);
git_signature *signature = git_signature_new(name, email, time, 0);
if ( signature == NULL)
return -1;
git_commit_set_committer(commit->commit, signature);
return 0; return 0;
} }
static PyObject * static PyObject *
Commit_get_author(Commit *commit) { Commit_get_author(Commit *commit) {
git_person *author; const git_signature *author = git_commit_author(commit->commit);
author = (git_person*)git_commit_author(commit->commit);
return build_person(git_person_name(author), return build_person(author->name,
git_person_email(author), author->email,
git_person_time(author)); author->when.time);
} }
static int static int
@@ -591,7 +591,11 @@ Commit_set_author(Commit *commit, PyObject *value) {
long long time; long long time;
if (!parse_person(value, &name, &email, &time)) if (!parse_person(value, &name, &email, &time))
return -1; return -1;
git_commit_set_author(commit->commit, name, email, time); git_signature *signature = git_signature_new(name, email, time, 0);
if ( signature == NULL)
return -1;
git_commit_set_author(commit->commit, signature);
return 0; return 0;
} }
@@ -1138,13 +1142,12 @@ Tag_set_name(Tag *self, PyObject *py_name) {
static PyObject * static PyObject *
Tag_get_tagger(Tag *tag) { Tag_get_tagger(Tag *tag) {
git_person *tagger; const git_signature *tagger = git_tag_tagger(tag->tag);
tagger = (git_person*)git_tag_tagger(tag->tag);
if (!tagger) if (!tagger)
Py_RETURN_NONE; Py_RETURN_NONE;
return build_person(git_person_name(tagger), return build_person(tagger->name,
git_person_email(tagger), tagger->email,
git_person_time(tagger)); tagger->when.time);
} }
static int static int
@@ -1153,7 +1156,12 @@ Tag_set_tagger(Tag *tag, PyObject *value) {
long long time; long long time;
if (!parse_person(value, &name, &email, &time)) if (!parse_person(value, &name, &email, &time))
return -1; return -1;
git_tag_set_tagger(tag->tag, name, email, time);
git_signature *signature = git_signature_new(name, email, time, 0);
if ( signature == NULL)
return -1;
git_tag_set_tagger(tag->tag, signature);
return 0; return 0;
} }