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

Method add

pygit2/index.py:208–228  ·  view source on GitHub ↗

Add or update an entry in the Index. If a path is given, that file will be added. The path must be relative to the root of the worktree and the Index must be associated with a repository. If an IndexEntry is given, that entry will be added or update in the I

(self, path_or_entry: 'IndexEntry | str | PathLike[str]')

Source from the content-addressed store, hash-verified

206 check_error(err, io=True)
207
208 def add(self, path_or_entry: 'IndexEntry | str | PathLike[str]') -> None:
209 """Add or update an entry in the Index.
210
211 If a path is given, that file will be added. The path must be relative
212 to the root of the worktree and the Index must be associated with a
213 repository.
214
215 If an IndexEntry is given, that entry will be added or update in the
216 Index without checking for the existence of the path or id.
217 """
218 if isinstance(path_or_entry, IndexEntry):
219 entry = path_or_entry
220 centry, str_ref = entry._to_c()
221 err = C.git_index_add(self._index, centry)
222 elif isinstance(path_or_entry, str) or hasattr(path_or_entry, '__fspath__'):
223 path = path_or_entry
224 err = C.git_index_add_bypath(self._index, to_bytes(path))
225 else:
226 raise TypeError('argument must be string, Path or IndexEntry')
227
228 check_error(err, io=True)
229
230 def add_conflict(
231 self, ancestor: 'IndexEntry', ours: 'IndexEntry', theirs: 'IndexEntry | None'

Callers 15

test_bare_indexFunction · 0.95
test_hashFunction · 0.45
test_add_submoduleFunction · 0.45
checkout_notifyMethod · 0.45
test_checkout_headFunction · 0.45
test_addFunction · 0.45
test_add_aspathFunction · 0.45
test_writeFunction · 0.45
test_create_entryFunction · 0.45

Calls 3

to_bytesFunction · 0.85
check_errorFunction · 0.85
_to_cMethod · 0.80

Tested by 14

test_bare_indexFunction · 0.76
test_hashFunction · 0.36
test_add_submoduleFunction · 0.36
checkout_notifyMethod · 0.36
test_checkout_headFunction · 0.36
test_addFunction · 0.36
test_add_aspathFunction · 0.36
test_writeFunction · 0.36
test_create_entryFunction · 0.36