treeverse / treeverse/dvc

`dvc diff --targets` reports unchanged file as modified when parent .dir changed

Open
#11,010 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
15.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Bug Report

Description

When using dvc diff --targets to check changes for a specific file that is tracked inside a .dir (directory tracking), DVC reports the file as "Modified" even when the file's hash is identical between revisions.

Reproduction Steps
  1. Have a directory tracked with .dvc (e.g., SciLife_FFPE_batch3.dvc)
  2. Between two commits, add new files to the directory (but don't modify existing files)
  3. Run dvc diff --targets <path_to_unchanged_file> -- <old_rev> <new_rev>
Observed Behavior
$ dvc diff --targets SciLife_FFPE_batch3/P29252_1021/images/manual_alignment/P29252_1021_V42L21-320-A1.json --show-hash -- 6ff9c0fe2947 e727db11d0ca
Modified:
    ef8f5c83..ef8f5c83  SciLife_FFPE_batch3/P29252_1021/images/manual_alignment/P29252_1021_V42L21-320-A1.json

files summary: 1 modified

Note: The hash is identical on both sides (ef8f5c83..ef8f5c83), yet the file is reported as "Modified".

Expected Behavior

The file should not be reported as modified since its hash is unchanged. Either:

  • Don't list it at all, or
  • Show it as "Unchanged" if included
Verification

dvc list --show-hash confirms the file has the same hash at both revisions:

$ dvc list --show-hash --rev 6ff9c0fe2947 . SciLife_FFPE_batch3/P29252_1021/images/manual_alignment/P29252_1021_V42L21-320-A1.json
ef8f5c8338a1ab9794d8ec183edc218b  P29252_1021_V42L21-320-A1.json

$ dvc list --show-hash --rev e727db11d0ca . SciLife_FFPE_batch3/P29252_1021/images/manual_alignment/P29252_1021_V42L21-320-A1.json
ef8f5c8338a1ab9794d8ec183edc218b  P29252_1021_V42L21-320-A1.json
Environment
  • DVC version: 3.x (latest)
  • OS: Linux
Analysis

It appears that when the parent directory's .dir manifest changes (e.g., new files added), dvc diff --targets incorrectly flags all files in that directory as "Modified" rather than checking individual file hashes.

This causes false positives when checking if a specific file has changed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with dvc diff --targets on the unchanged file across the two revisions, then compare the result with dvc list --show-hash. Trace how the changed parent .dir manifest is handled for targeted files. Done means an unchanged file with the same hash is not reported as Modified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.