Skip to main content

try_get_changed_files

Function try_get_changed_files 

Source
pub fn try_get_changed_files(
    root: &Path,
    git_ref: &str,
) -> Result<FxHashSet<PathBuf>, ChangedFilesError>
Expand description

Get files changed since a git ref. Returns Err (with details) when the git invocation itself failed, so callers can choose between warn-and-ignore and hard-error behavior.

Includes both:

  • committed changes from the merge-base range git_ref...HEAD
  • tracked staged/unstaged changes from HEAD to the current worktree
  • untracked files not ignored by Git

This keeps --changed-since useful for local validation instead of only reflecting the last committed HEAD.

All paths in the returned set are absolute and rooted at the canonical git toplevel, not at root. This matters when the LSP / CLI is invoked from a subdirectory of the repository (e.g., a Turborepo workspace at apps/web): git diff emits root-relative paths, and we need to join them against the actual repo root rather than the caller’s cwd.