Skip to main content

Module repo_read_diff

Module repo_read_diff 

Source
Expand description

In-process repository reads: the difference between two sorted entry lists and the output spellings. What: The difference between two sorted lists of tree-like entries (a flattened tree, an index), in Git’s raw and name-only spellings, and the pathspec forms and filters the wrapper’s own queries use. Why: diff-index --cached, diff --cached and diff-tree print exactly these lines for the plain cases; every case where Git’s output depends on more than the two lists (a file that became a directory, a gitlink, a possible rename) returns None, so Git answers it.

In TS you’d write (pseudocode):

const changes = diffSorted(oldEntries, newEntries); // undefined: ask Git
const text = rawLines(changes) // ":100644 100644 <old> <new> M\0path\0"

Structs§

Change
One changed path.
PathFilter
What: The pathspecs a query names: the plain relative form (at the top of the worktree only) or :(top,literal)path, or :/ for everything. Why: A glob or any other magic changes what matches, so those return None; matching a plain name is “the path, or anything below it”.

Functions§

diff_sorted
What: The changes from old to new, both sorted by path; None when a path is a file on one side and a directory on the other or when a gitlink is involved. Why: Those are the cases whose ordering or spelling Git decides by more than the lists.
name_lines
The -z name-only lines: <path>\0.
parse_diff_filter
The statuses --diff-filter keeps; None keeps all. Only the upper-case letters A D M T are understood.
raw_lines
The -z raw lines: :<old mode> <new mode> <old id> <new id> <status>\0<path>\0.
select
Keep the changes the filter and statuses name.