pub fn worktree_diff(worktree_path: &Path, base_ref: &str) -> WorktreeDiffExpand description
Compute the aggregate diff for a live worktree.
worktree_path is the absolute path to the worktree directory.
base_branch is the branch the worktree was forked from (e.g. HEAD of the
main checkout at the time git worktree add was run — the merge-base is used
to compute only the run’s own changes, not the full history divergence).
Returns a zero-change WorktreeDiff on any git failure so callers can
render “no changes” rather than an error.
Stages all untracked and modified files via git add -A before diffing.
This is safe because the worktree is ephemeral and about to be destroyed;
mutating the index ensures new files created by the agent appear in the diff
and aren’t silently dropped by git diff HEAD (which skips untracked files).