`dvc diff <rev>` reports all-deleted/0-added for outputs after splitting a single-dir `.dvc` into per-subfolder `.dvc` files (3.66.1)
Description
After refactoring a single dir-output .dvc (e.g. review.dvc tracking
review/) into multiple sub-folder .dvc files (review/<name>.dvc,
each with path: <name> relative to its parent), dvc diff HEAD
(i.e. HEAD vs workspace) reports every file under the refactored
subtree as deleted, with 0 added and 0 modified, even though:
dvc statusreports the workspace fully in sync.- The files all exist on disk at the expected paths.
- The dir-hash
.dircache files referenced by each new.dvcare present and enumerate correctly. - HEAD's
.dvcfiles are byte-identical to workspace's.dvcfiles (git statusclean). dvc diff HEAD HEAD(rev-to-rev) is correctly empty.dvc diff HEAD~1 HEAD(other rev-to-rev pairings) work correctly.dvc diff HEAD --targets <unaffected-subtree>works correctly.
The zero-added/zero-modified counts suggest the workspace-side enumeration is returning an empty file list for the refactored outputs, while the HEAD-side enumeration correctly expands the dir caches; the diff then attributes all HEAD-side files to "deleted."
Reproduction
Pre-refactor state:
project/
review.dvc # outs: [{path: review, md5: <dir-hash>}]
review/
after_cma_phase1/
clinician_files/
...
Refactor (each commit does one):
# Remove the umbrella tracker, leaving files in place
dvc remove review.dvc
git rm review.dvc
# Track each subfolder individually
dvc add review/after_cma_phase1
dvc add review/clinician_files
dvc add review/edf_files
# ...
git add review/*.dvc
git commit
Each new review/<name>.dvc looks like:
```yaml outs:
- md5: 69c24de62577c8e011842eaaa013ffc6.dir size: 1195692789 nfiles: 140 hash: md5 path: after_cma_phase1 ```
Then:
```bash $ dvc status Data and pipelines are up to date.
$ dvc diff HEAD HEAD
(empty, as expected)
$ dvc diff HEAD HEAD~1
(correct diff for the actual rev-to-rev change)
$ dvc diff HEAD --json | jq '{added, deleted, modified} | map_values(length)' { "added": 0, "deleted": 11957, "modified": 0 } ```
All 11,957 "deleted" paths still exist on disk and are correctly
listed inside their respective .dir cache files.
Things tried that did not help
dvc commit -f(no-op sincedvc statusis clean).- Running
dvc diff HEADfrom the subdirectory containing the refactored.dvcfiles. - Verifying every
.dircache file for each new sub-folder.dvcis present and well-formed.
Workarounds
dvc statusfor sync checks (authoritative; not affected).- Use commit-to-commit
dvc diff <rev1> <rev2>(not affected). - Scope HEAD-vs-workspace diffs to unaffected targets:
dvc diff HEAD --targets <other-target>(not affected).
Expected behavior
dvc diff HEAD with no workspace changes should report an empty
diff, matching dvc status.
Environment
``` DVC version: 3.66.1 (brew) CPython 3.14.2 Linux 6.18.28-1-lts (x86_64) glibc 2.43 ```
Repo layout: monorepo, DVC project lives in a subdirectory of the git repo (git toplevel and DVC root are not the same path). Remote: local FS path remote.
I tried to reproduce this on main (3.67.2.dev12+gf74c1c0e7) and couldn't get the all-deleted result — dvc diff HEAD correctly returns an empty diff after the refactor. To make sure I was matching the described setup I tried a couple of variants:
- Umbrella
review.dvc(single dir output) →dvc remove review.dvc→dvc add review/alpha+dvc add review/beta, each producing areview/<name>.dvcwith a relativepath: <name>, then committed.git statusclean,dvc statusup to date. - Both with the git root == DVC root, and with the DVC root in a subdirectory of the git repo (
dvc init --subdir).
In every case dvc diff HEAD (and --json) reported {added: 0, deleted: 0, modified: 0}.
Since my repro is much smaller than yours (a handful of files vs ~12k) and on a newer version, it'd help to narrow down what's different. Could you share:
- Does it still reproduce on the latest
main? (pip install git+https://github.com/iterative/dvc) — there's a chance a diff/index change since 3.66.1 already fixed it. - A minimal reproducer — the smallest tree + sequence of commands that still shows
deleted > 0. If you can get it down to 2–3 subfolders that would pin the trigger quickly. - The exact layout of the split
.dvcfiles — are any of them nested more than one level deep (review/a/b.dvc), and is there any remaining umbrella/parent.dvcstill tracking part of the same subtree? - Whether wiping the local data index changes anything: does
dvc diff HEADbehave differently right after a fresh clone, or afterrm -rf .dvc/tmp/ a fresh.dvc/index?dvc diff's workspace side is built from the data index, so a stale index is one candidate for the empty workspace-side enumeration you suspected.
Happy to dig into the workspace-side build_data_index path once I can get it to fail locally.