To understand the diff APIs, you should know the following terms:
diff
or diff list
represents the cumulative list of differences
between two snapshots of a repository (possibly filtered by a set of
file name patterns). This is the git_diff_list
object.delta
is a file pair with an old and new revision. The old version
may be absent if the file was just created and the new version may be
absent if the file was deleted. A diff is mostly just a list of deltas.binary
file / delta is a file (or pair) for which no text diffs
should be generated. A diff list can contain delta entries that are
binary, but no diff content will be output for those files. There is
a base heuristic for binary detection and you can further tune the
behavior with git attributes or diff flags and option settings.hunk
is a span of modified lines in a delta along with some stable
surrounding context. You can configure the amount of context and other
properties of how hunks are generated. Each hunk also comes with a
header that described where it starts and ends in both the old and new
versions in the delta.line
is a range of characters inside a hunk. It could be a context
line (i.e. in both old and new versions), an added line (i.e. only in
the new version), or a removed line (i.e. only in the old version).
Unfortunately, we don't know anything about the encoding of data in the
file being diffed, so we cannot tell you much about the line content.
Line data will not be NUL-byte terminated, however, because it will be
just a span of bytes inside the larger file.The diff list object that contains all individual file deltas
The diff patch is used to store all the text diffs for a delta
Description of one side of a diff entry
Description of changes to one entry
Structure describing options about how the diff should be executed
Structure describing a hunk of a diff
Pluggable similarity metric
Control behavior of rename and copy detection
Flags for diff options in via the flags
value in the git_diff_options
.
Flags for the delta object and the file objects on each side
What type of change is described by a git_diff_delta?
Line origin constants
Flags to control the behavior of diff rename/copy detection
Diff notification callback function
When iterating over a diff, callback that will be made per file
When iterating over a diff, callback that will be made per hunk
When iterating over a diff, callback that will be made per text diff line
Deallocate a diff list
Create a diff list with the difference between two tree objects
Create a diff list between a tree and repository index
Create a diff list between the repository index and the workdir directory
Create a diff list between a tree and the working directory
Merge one diff list into another
Transform a diff list marking file renames, copies, etc
Loop over all deltas in a diff list issuing callbacks
Iterate over a diff generating text output like "git diff --name-status"
Look up the single character abbreviation for a delta status code
Iterate over a diff generating text output like "git diff"
Query how many diff records are there in a diff list
Query how many diff deltas are there in a diff list filtered by type
Return the diff delta and patch for an entry in the diff list
Free a git_diff_patch object
Get the delta associated with a patch
Get the number of hunks in a patch
Get line counts of each type in a patch
Get the information about a hunk in a patch
Get the number of lines in a hunk
Get data about a line in a hunk of a patch
Serialize the patch to text via callback
Get the content of a patch as a single diff text
Directly run a diff on two blobs
Directly run a diff between a blob and a buffer