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)
| 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.""" |