unstage

Function unstage 

Source
pub fn unstage(paths: &[&str]) -> Result<()>
Expand description

Unstage specific paths without touching working tree contents.

Thin wrapper over git restore --staged <paths...> which only affects the index (inverse of git add). Unlike using libgit2 reset_default, this avoids resurrecting deleted files whose blobs no longer exist on disk.

§Errors

  • Spawning or executing the git restore --staged command fails.

§Rationale

Defers to porcelain for correctness (handles intent, pathspec edge cases) instead of manually editing the index via libgit2 which exhibited unintended side effects during experimentation.

§Future Work

  • Optionally fall back to libgit2 for environments lacking a git binary.
  • Capture command stderr and surface as richer context on failure.