From 2044699a53bf5902623e4d6a7cb9bca70d455931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 13 Feb 2012 14:30:32 +0100 Subject: [PATCH] Add TreeBuilder_write --- pygit2.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pygit2.c b/pygit2.c index e310975..0d2796a 100644 --- a/pygit2.c +++ b/pygit2.c @@ -1636,9 +1636,25 @@ TreeBuilder_insert(TreeBuilder *self, TreeEntry *py_tentry) Py_RETURN_NONE; } +static PyObject * +TreeBuilder_write(TreeBuilder *self, Repository *py_repo) +{ + int err; + git_oid oid; + git_repository *repo = py_repo->repo; + + err = git_treebuilder_write(&oid, repo, self->bld); + if (err < 0) + return Error_set(err); + + return git_oid_to_python(&oid); +} + static PyMethodDef TreeBuilder_methods[] = { {"insert", (PyCFunction)TreeBuilder_insert, METH_O, "Insert or replace an entry in the treebuilder"}, + {"write", (PyCFunction)TreeBuilder_write, METH_O, + "Write the tree to the given repository"}, {NULL, NULL, 0, NULL} };