thodg/libgit2/docs/diff-internals.md

Download

Diff is broken into four phases:

  1. Building a list of things that have changed. These changes are called deltas (git_diff_delta objects) and are grouped into a git_diff_list.
  2. Applying file similarity measurement for rename and copy detection (and to potentially split files that have changed radically). This step is optional.
  3. Computing the textual diff for each delta. Not all deltas have a meaningful textual diff. For those that do, the textual diff can either be generated on the fly and passed to output callbacks or can be turned into a git_diff_patch object.
  4. Formatting the diff and/or patch into standard text formats (such as patches, raw lists, etc).

In the source code, step 1 is implemented in src/diff.c, step 2 in src/diff_tform.c, step 3 in src/diff_patch.c, and step 4 in src/diff_print.c. Additionally, when it comes to accessing file content, everything goes through diff drivers that are implemented in src/diff_driver.c.

External Objects

Internal Objects


Source

Download