Skip to main content

classify_worktree_entry_for_add

Function classify_worktree_entry_for_add 

Source
pub fn classify_worktree_entry_for_add(
    params: &WorktreeAddRefreshParams<'_>,
) -> Result<WorktreeAddRefresh>
Expand description

Decide whether staging must re-read and re-hash a tracked path.

Mirrors the fast paths in diff_index_to_worktree and Git’s refresh_index / add_file_to_index: trust matching stat when the entry is not racy and index_stat_cache_trustworthy allows it; re-hash when stat matches but the entry is racy or when stat differs; apply CRLF-aware hashing like staging.

Returns WorktreeAddRefresh::UpToDate when the index entry already matches the worktree and no restaging is required; other variants describe mode/stat-only updates or a full restage.

§Errors

Returns Error::Io when the worktree file cannot be read for content verification.