Skip to main content

history

Function history 

Source
pub fn history(repo: &Path, max: usize) -> Result<String, String>
Expand description

Runs git log --first-parent in repo and returns output for parse_history.

--first-parent is load-bearing, not a tidying flag. Without it, the position of a commit in git log output depends on git’s date-and-topology ordering heuristics, so “reverted within N commits” would mean something slightly different in every branchy history — two commits could sit 2 or 3 apart depending on how their timestamps happened to fall. Along first-parent order the listing is the mainline, so distance is exactly “N landings later”, which is the quantity the window is trying to express.

It also fixes what gets counted: first-parent order lists the merges that landed on this branch and skips commits internal to the branches they merged, which is the population D23 cares about.

max caps the commits scanned; 0 means the whole history. Shelling out rather than linking a git library is the workspace’s standing posture.

§Errors

Returns a description if git cannot be spawned or exits nonzero.