diff --git a/src/commit.c b/src/commit.c index b8e8fbf..74b1ecc 100644 --- a/src/commit.c +++ b/src/commit.c @@ -152,7 +152,7 @@ PyDoc_STRVAR(Commit_parents__doc__, "The list of parent commits."); PyObject * Commit_parents__get__(Commit *self) { - git_repository *repo; + Repository *py_repo; unsigned int i, parent_count; const git_oid *parent_oid; git_commit *parent; @@ -165,7 +165,7 @@ Commit_parents__get__(Commit *self) if (!list) return NULL; - repo = git_object_owner((git_object*)self->commit); + py_repo = self->repo; for (i=0; i < parent_count; i++) { parent_oid = git_commit_parent_id(self->commit, i); if (parent_oid == NULL) { @@ -174,13 +174,13 @@ Commit_parents__get__(Commit *self) return NULL; } - err = git_commit_lookup(&parent, repo, parent_oid); + err = git_commit_lookup(&parent, py_repo->repo, parent_oid); if (err < 0) { Py_DECREF(list); return Error_set_oid(err, parent_oid, GIT_OID_HEXSZ); } - py_parent = wrap_object((git_object*)parent, self->repo); + py_parent = wrap_object((git_object*)parent, py_repo); if (py_parent == NULL) { Py_DECREF(list); return NULL; diff --git a/src/index.c b/src/index.c index 3b637a8..3c73f21 100644 --- a/src/index.c +++ b/src/index.c @@ -175,9 +175,9 @@ PyDoc_STRVAR(Index_diff_to_tree__doc__, PyObject * Index_diff_to_tree(Index *self, PyObject *args) { + Repository *py_repo; git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_diff_list *diff; - git_repository* repo; int err; Tree *py_tree = NULL; @@ -186,12 +186,13 @@ Index_diff_to_tree(Index *self, PyObject *args) &opts.context_lines, &opts.interhunk_lines)) return NULL; - repo = git_tree_owner(py_tree->tree); - err = git_diff_tree_to_index(&diff, repo, py_tree->tree, self->index, &opts); + py_repo = py_tree->repo; + err = git_diff_tree_to_index(&diff, py_repo->repo, py_tree->tree, + self->index, &opts); if (err < 0) return Error_set(err); - return wrap_diff(diff, self->repo); + return wrap_diff(diff, py_repo); } diff --git a/src/object.c b/src/object.c index e602da1..193efdc 100644 --- a/src/object.c +++ b/src/object.c @@ -99,15 +99,13 @@ PyDoc_STRVAR(Object_read_raw__doc__, PyObject * Object_read_raw(Object *self) { - git_repository *repo; const git_oid *oid; git_odb_object *obj; PyObject *aux; - repo = git_object_owner(self->obj); oid = git_object_id(self->obj); - obj = Repository_read_raw(repo, oid, GIT_OID_HEXSZ); + obj = Repository_read_raw(self->repo->repo, oid, GIT_OID_HEXSZ); if (obj == NULL) return NULL; diff --git a/src/reference.c b/src/reference.c index 0ed45aa..e01eb47 100644 --- a/src/reference.c +++ b/src/reference.c @@ -228,14 +228,12 @@ Reference_target__set__(Reference *self, PyObject *py_target) char *c_name; int err; git_reference *new_ref; - git_repository *repo; CHECK_REFERENCE_INT(self); /* Case 1: Direct */ if (GIT_REF_OID == git_reference_type(self->reference)) { - repo = git_reference_owner(self->reference); - err = py_oid_to_git_oid_expand(repo, py_target, &oid); + err = py_oid_to_git_oid_expand(self->repo->repo, py_target, &oid); if (err < 0) return err; diff --git a/src/tree.c b/src/tree.c index 378792d..e0abbbd 100644 --- a/src/tree.c +++ b/src/tree.c @@ -291,20 +291,19 @@ Tree_diff_to_workdir(Tree *self, PyObject *args) { git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_diff_list *diff; - git_repository* repo; + Repository *py_repo; int err; if (!PyArg_ParseTuple(args, "|IHH", &opts.flags, &opts.context_lines, &opts.interhunk_lines)) return NULL; - repo = git_tree_owner(self->tree); - err = git_diff_tree_to_workdir(&diff, repo, self->tree, &opts); - + py_repo = self->repo; + err = git_diff_tree_to_workdir(&diff, py_repo->repo, self->tree, &opts); if (err < 0) return Error_set(err); - return wrap_diff(diff, self->repo); + return wrap_diff(diff, py_repo); } @@ -330,7 +329,7 @@ Tree_diff_to_index(Tree *self, PyObject *args, PyObject *kwds) { git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_diff_list *diff; - git_repository* repo; + Repository *py_repo; int err; Index *py_idx = NULL; @@ -340,12 +339,13 @@ Tree_diff_to_index(Tree *self, PyObject *args, PyObject *kwds) &opts.interhunk_lines)) return NULL; - repo = git_tree_owner(self->tree); - err = git_diff_tree_to_index(&diff, repo, self->tree, py_idx->index, &opts); + py_repo = self->repo; + err = git_diff_tree_to_index(&diff, py_repo->repo, self->tree, + py_idx->index, &opts); if (err < 0) return Error_set(err); - return wrap_diff(diff, self->repo); + return wrap_diff(diff, py_repo); } @@ -375,10 +375,10 @@ Tree_diff_to_tree(Tree *self, PyObject *args, PyObject *kwds) git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_diff_list *diff; git_tree *from, *to, *tmp; - git_repository* repo; + Repository *py_repo; int err, swap = 0; char *keywords[] = {"obj", "flags", "context_lines", "interhunk_lines", - "swap", NULL}; + "swap", NULL}; Tree *py_tree = NULL; @@ -388,21 +388,20 @@ Tree_diff_to_tree(Tree *self, PyObject *args, PyObject *kwds) &opts.interhunk_lines, &swap)) return NULL; - repo = git_tree_owner(self->tree); + py_repo = self->repo; to = (py_tree == NULL) ? NULL : py_tree->tree; from = self->tree; if (swap > 0) { - tmp = from; - from = to; - to = tmp; + tmp = from; + from = to; + to = tmp; } - err = git_diff_tree_to_tree(&diff, repo, from, to, &opts); - + err = git_diff_tree_to_tree(&diff, py_repo->repo, from, to, &opts); if (err < 0) return Error_set(err); - return wrap_diff(diff, self->repo); + return wrap_diff(diff, py_repo); }