Diff the index against the working directory. Return a object with the differences between the index and the working copy. Parameters: flags A combination of enums.DiffOption constants. context_lines The number of unchanged l
(
self,
flags: DiffOption = DiffOption.NORMAL,
context_lines: int = 3,
interhunk_lines: int = 0,
)
| 267 | check_error(err, io=True) |
| 268 | |
| 269 | def diff_to_workdir( |
| 270 | self, |
| 271 | flags: DiffOption = DiffOption.NORMAL, |
| 272 | context_lines: int = 3, |
| 273 | interhunk_lines: int = 0, |
| 274 | ) -> Diff: |
| 275 | """ |
| 276 | Diff the index against the working directory. Return a <Diff> object |
| 277 | with the differences between the index and the working copy. |
| 278 | |
| 279 | Parameters: |
| 280 | |
| 281 | flags |
| 282 | A combination of enums.DiffOption constants. |
| 283 | |
| 284 | context_lines |
| 285 | The number of unchanged lines that define the boundary of a hunk |
| 286 | (and to display before and after). |
| 287 | |
| 288 | interhunk_lines |
| 289 | The maximum number of unchanged lines between hunk boundaries |
| 290 | before the hunks will be merged into a one. |
| 291 | """ |
| 292 | repo = self._repo |
| 293 | if repo is None: |
| 294 | raise ValueError('diff needs an associated repository') |
| 295 | |
| 296 | copts = ffi.new('git_diff_options *') |
| 297 | err = C.git_diff_options_init(copts, 1) |
| 298 | check_error(err) |
| 299 | |
| 300 | copts.flags = int(flags) |
| 301 | copts.context_lines = context_lines |
| 302 | copts.interhunk_lines = interhunk_lines |
| 303 | |
| 304 | cdiff = ffi.new('git_diff **') |
| 305 | err = C.git_diff_index_to_workdir(cdiff, repo._repo, self._index, copts) |
| 306 | check_error(err) |
| 307 | |
| 308 | return Diff.from_c(bytes(ffi.buffer(cdiff)[:]), repo) |
| 309 | |
| 310 | def diff_to_tree( |
| 311 | self, |