diff --git a/dvc/command/diff.py b/dvc/command/diff.py index 026ea1372..42113f900 100644 --- a/dvc/command/diff.py +++ b/dvc/command/diff.py @@ -72,9 +72,7 @@ class CmdDiff(CmdBase): def run(self): try: - diff = self.repo.diff( - self.args.a_ref, self.args.b_ref, target=self.args.target - ) + diff = self.repo.diff(self.args.a_ref, self.args.b_ref) if not any(diff.values()): return 0 @@ -124,15 +122,6 @@ def add_parser(subparsers, parent_parser): ), nargs="?", ) - diff_parser.add_argument( - "-t", - "--target", - help=( - "Source path to a data file or directory. Default None. " - "If not specified, compares all files and directories " - "that are under DVC control in the current working space." - ), - ) diff_parser.add_argument( "--show-json", help="Format the output into a JSON", diff --git a/dvc/repo/diff.py b/dvc/repo/diff.py index 89676f24b..1945bd1f5 100644 --- a/dvc/repo/diff.py +++ b/dvc/repo/diff.py @@ -46,12 +46,10 @@ def _diffables_from_output(output): @locked -def diff(self, a_ref="HEAD", b_ref=None, *, target=None): +def diff(self, a_ref="HEAD", b_ref=None): """ By default, it compares the working tree with the last commit's tree. - When a `target` path is given, it only shows that file's comparison. - This implementation differs from `git diff` since DVC doesn't have the concept of `index`, but it keeps the same interface, thus, `dvc diff` would be the same as `dvc diff HEAD`. @@ -67,7 +65,6 @@ def diff(self, a_ref="HEAD", b_ref=None, *, target=None): for stage in self.stages for out in stage.outs for diffable in _diffables_from_output(out) - if not target or target == str(out) ) old = outs[a_ref] diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index b64839029..8c2d3b061 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -22,7 +22,7 @@ _dvc_checkout='-d --with-deps -R --recursive -f --force --relink $(compgen -G *. _dvc_commit='-f --force -d --with-deps -R --recursive $(compgen -G *.dvc)' _dvc_config='-u --unset --local --system --global' _dvc_destroy='-f --force' -_dvc_diff='-t --target --show-json --checksums' +_dvc_diff='-t --show-json --checksums' _dvc_fetch='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -R --recursive $(compgen -G *.dvc)' _dvc_get_url='' _dvc_get='-o --out --rev --show-url' diff --git a/scripts/completion/dvc.zsh b/scripts/completion/dvc.zsh index 08ed4f607..03f9fa69c 100644 --- a/scripts/completion/dvc.zsh +++ b/scripts/completion/dvc.zsh @@ -97,7 +97,6 @@ _dvc_destroy=( ) _dvc_diff=( - {-t,--target}"[Source path to a data file or directory.]:Target files:" "--show-json[Format the output into a JSON]" "--checksums[Display checksums for each entry]" {1,2}":Git revision (e.g. branch, tag, SHA):" diff --git a/tests/func/test_diff.py b/tests/func/test_diff.py index 1ffb1c699..caaa7e074 100644 --- a/tests/func/test_diff.py +++ b/tests/func/test_diff.py @@ -111,35 +111,6 @@ def test_refs(tmp_dir, scm, dvc): dvc.diff("missing") -def test_target(tmp_dir, scm, dvc): - tmp_dir.dvc_gen("foo", "foo") - tmp_dir.dvc_gen("bar", "bar") - scm.add([".gitignore", "foo.dvc", "bar.dvc"]) - scm.commit("lowercase") - - tmp_dir.dvc_gen("foo", "FOO") - tmp_dir.dvc_gen("bar", "BAR") - scm.add(["foo.dvc", "bar.dvc"]) - scm.commit("uppercase") - - assert dvc.diff("HEAD~1", target="foo") == { - "added": [], - "deleted": [], - "modified": [ - { - "filename": "foo", - "checksum": {"old": digest("foo"), "new": digest("FOO")}, - } - ], - } - - assert dvc.diff("HEAD~1", target="missing") == { - "added": [], - "deleted": [], - "modified": [], - } - - def test_directories(tmp_dir, scm, dvc): tmp_dir.dvc_gen({"dir": {"1": "1", "2": "2"}}, commit="add a directory") tmp_dir.dvc_gen({"dir": {"3": "3"}}, commit="add a file")