fix: prune the store the caller asked for

This commit is contained in:
2026-09-08 10:19:08 +00:00
parent 01b0b5c2dd
commit 432fa12c53

View File

@@ -99,7 +99,7 @@ fn restore_one(repo: &Repo, path: &Path, report: &Report) -> Result<()> {
fs::remove_file(&src).with_context(|| format!("removing {}", src.display()))?;
move_path(&stored, &src)?;
prune_empty(stored.parent(), &store_root()?);
prune_empty(stored.parent(), &repo.base);
report.line("restored", &rel);
Ok(())
@@ -425,22 +425,24 @@ fn list_others(repo: &Repo, ignored: bool, pathspecs: &[PathBuf]) -> Result<Vec<
struct Repo {
root: PathBuf,
store: PathBuf,
// the configured store root, above the per-repository directories
base: PathBuf,
}
impl Repo {
fn discover(store: Option<&Path>) -> Result<Self> {
let root = git_root()?;
let store = match store {
let base = match store {
Some(store) => store.to_path_buf(),
None => store_root()?,
};
Ok(Self {
root: root.clone(),
store: store.join(repo_components(&root)?),
store: base.join(repo_components(&root)?),
root,
base,
})
}
fn relative(&self, src: &Path) -> Result<PathBuf> {
let rel = src.strip_prefix(&self.root).map_err(|_| {
anyhow!(