MCPcopy Create free account
hub / github.com/libgit2/pygit2 / Repository_TreeBuilder

Function Repository_TreeBuilder

src/repository.c:1848–1898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1846 "Create a TreeBuilder object for this repository.");
1847
1848PyObject *
1849Repository_TreeBuilder(Repository *self, PyObject *args)
1850{
1851 TreeBuilder *builder;
1852 git_treebuilder *bld;
1853 PyObject *py_src = NULL;
1854 git_oid oid;
1855 git_tree *tree = NULL;
1856 git_tree *must_free = NULL;
1857 int err;
1858
1859 if (!PyArg_ParseTuple(args, "|O", &py_src))
1860 return NULL;
1861
1862 if (py_src) {
1863 if (PyObject_TypeCheck(py_src, &TreeType)) {
1864 Tree *py_tree = (Tree *)py_src;
1865 if (py_tree->repo->repo != self->repo) {
1866 /* return Error_set(GIT_EINVALIDARGS); */
1867 return Error_set(GIT_ERROR);
1868 }
1869 if (Object__load((Object*)py_tree) == NULL) { return NULL; } // Lazy load
1870 tree = py_tree->tree;
1871 } else {
1872 err = py_oid_to_git_oid_expand(self->repo, py_src, &oid);
1873 if (err < 0)
1874 return NULL;
1875
1876 err = git_tree_lookup(&tree, self->repo, &oid);
1877 if (err < 0)
1878 return Error_set(err);
1879 must_free = tree;
1880 }
1881 }
1882
1883 err = git_treebuilder_new(&bld, self->repo, tree);
1884 if (must_free != NULL)
1885 git_tree_free(must_free);
1886
1887 if (err < 0)
1888 return Error_set(err);
1889
1890 builder = PyObject_New(TreeBuilder, &TreeBuilderType);
1891 if (builder) {
1892 builder->repo = self;
1893 builder->bld = bld;
1894 Py_INCREF(self);
1895 }
1896
1897 return (PyObject*)builder;
1898}
1899
1900PyDoc_STRVAR(Repository_default_signature__doc__, "Return the signature according to the repository's configuration");
1901

Callers

nothing calls this directly

Calls 3

Error_setFunction · 0.85
Object__loadFunction · 0.85
py_oid_to_git_oid_expandFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…