Skip to content

Sparse full clone: a stopped merge/cherry-pick/rebase resurrects a file the other side deleted cleanly outside the view #238

Closed

Description

@tonibergholm-codento

Found while reviewing #236 (reproduced on the base commit too, so it predates it). Full clones with a sparse spec only; partial clones are correct because they graft out-of-view paths from the decided root.

Repro (merge, cherry-pick and rebase behave the same): base has src/a.txt and docs/old.txt; the other branch edits src/a.txt and deletes docs/old.txt; ours edits src/a.txt; sparse spec is src/. Resolve the conflict and complete. Without sparse docs/old.txt is gone; with sparse src/ it comes back, silently losing the deletion from history.

Cause: in the completion code (snapshot_files, crates/repo/src/repo.rs ~704-720), parents are still used as a source for paths missing from the decided root; then the out-of-sparse rule (~738-741) copies docs/old.txt back from the tip. The comment at ~648-656 says a path missing from the decided root was decided deleted, but that rule is applied to the picked commit and not to the tip / merge head.

Suggested fix: when a decided root exists, do not use the parents for the out-of-sparse carry (keep them only as the fallback for old state with no decided root). Also amend ADR-0034 refinement 5 (~:185), which says completion carries out-of-view paths only from the decided root. Add tests for merge, pick and rebase with a clean out-of-view deletion, and an out-of-view clean add/modify.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions