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.
- Path
Filter - 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 returnNone; matching a plain name is “the path, or anything below it”.
Functions§
- diff_
sorted - What:
The changes from
oldtonew, both sorted by path;Nonewhen 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
-zname-only lines:<path>\0. - parse_
diff_ filter - The statuses
--diff-filterkeeps;Nonekeeps all. Only the upper-case lettersA D M Tare understood. - raw_
lines - The
-zraw lines::<old mode> <new mode> <old id> <new id> <status>\0<path>\0. - select
- Keep the changes the filter and statuses name.