Skip to main content

stage

Function stage 

Source
pub fn stage(dest: &Path, body: &str, exec: bool) -> Result<Staged>
Expand description

Write body to a sibling of dest, ready to be renamed into place.

A SIBLING, in the destination’s own directory, which is not a detail: fs::rename across filesystems fails with EXDEV, and .git is a mount point often enough (a bind mount, a container volume, a separate partition for a large repo) that staging in /tmp would turn a rename that cannot fail into one that fails on exactly the machines hardest to reproduce.

The temporary name carries the pid so two installs racing in the same repository do not stage over each other, and starts with a dot so it does not look like a hook to anyone reading the directory.