pub fn get_worktree_changes<F>(
root: impl AsRef<Path>,
keep: F,
) -> Result<WorktreeChanges>Expand description
List working-tree changes against HEAD.
This is what makes freshness honest. Before 1.7.2 the check compared
git rev-parse HEAD to the indexed commit and then sampled the mtimes of the
first TEN indexed files — so an edit to any other file, any untracked file, and
any deletion all reported fresh with can_trust_results: true. That is the
primary agent workflow: edit, then search, before committing.
Flags, each load-bearing:
-z— porcelain v1 C-quotes paths containing spaces, non-ASCII or backslashes.-zemits raw NUL-separated paths and never quotes, so no unescaping is needed.--untracked-files=all— list new files individually rather than just their directory, otherwise a new file inside an existing directory is invisible.--no-renames— decomposeR old -> newinto a delete plus an add, which is exactly what an index must do with a rename, and removes all rename parsing.--ignored=no—.gitignored paths are not indexed, so they cannot make the index stale.
keep filters paths down to those the indexer would actually index. Without it,
editing README.md or anything under target/ would mark the index permanently
stale, and the cure would be worse than the disease.