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