Skip to main content

active_workdir

Function active_workdir 

Source
pub fn active_workdir(
    store: &BufferStoreHandle,
    scopes: &RepoScopes,
    active: BufferId,
) -> Option<PathBuf>
Expand description

MR.4: the repository an action acts on — the one question every magit action body asks, answered in one place.

Design §4 is emphatic about this and about why: the entry points and the action bodies are two populations, and fixing only the first is worse than fixing neither. A status buffer showing repo B whose s stages into repo A is data-loss-shaped, and it is exactly what a half-migration produces.

The three questions are design §2’s, with the first one read rather than re-resolved:

  1. The active buffer is a magit buffer → the repository it was recorded against (or, for a buffer opened from inside another one, recovered from its label). Never re-derived from the cwd: the whole point is that this buffer’s repository is not the process’s.
  2. The active buffer has a file → that file’s repository. This is the C-c g -from-a-file case: the dispatch was opened over a file, so the operation belongs to that file’s checkout.
  3. Otherwise the working directory — unchanged, and still the answer for a fresh editor with nothing open.