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

Method write_tree

pygit2/index.py:158–179  ·  view source on GitHub ↗

Create a tree out of the Index. Return the object of the written tree. The contents of the index will be written out to the object database. If there is no associated repository, 'repo' must be passed. If there is an associated repository and 'repo' is

(self, repo: 'Repository | None' = None)

Source from the content-addressed store, hash-verified

156 check_error(err)
157
158 def write_tree(self, repo: 'Repository | None' = None) -> Oid:
159 """Create a tree out of the Index. Return the <Oid> object of the
160 written tree.
161
162 The contents of the index will be written out to the object
163 database. If there is no associated repository, 'repo' must be
164 passed. If there is an associated repository and 'repo' is
165 passed, then that repository will be used instead.
166
167 It returns the id of the resulting tree.
168 """
169 coid = ffi.new('git_oid *')
170
171 repo = repo or self._repo
172
173 if repo:
174 err = C.git_index_write_tree_to(coid, self._index, repo._repo)
175 else:
176 err = C.git_index_write_tree(coid, self._index)
177
178 check_error(err)
179 return Oid(raw=bytes(ffi.buffer(coid)[:]))
180
181 def remove(self, path: PathLike[str] | str, level: int = 0) -> None:
182 """Remove an entry from the Index."""

Callers 9

test_merge_commitsFunction · 0.80
test_merge_treesFunction · 0.80
test_merge_manyFunction · 0.80
test_merge_octopusFunction · 0.80
test_read_treeFunction · 0.80
test_write_treeFunction · 0.80
test_write_tree_toFunction · 0.80
test_create_entryFunction · 0.80
test_create_entry_aspathFunction · 0.80

Calls 1

check_errorFunction · 0.85

Tested by 9

test_merge_commitsFunction · 0.64
test_merge_treesFunction · 0.64
test_merge_manyFunction · 0.64
test_merge_octopusFunction · 0.64
test_read_treeFunction · 0.64
test_write_treeFunction · 0.64
test_write_tree_toFunction · 0.64
test_create_entryFunction · 0.64
test_create_entry_aspathFunction · 0.64