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]')
| 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' |