diff --git a/dvc/repo/params/diff.py b/dvc/repo/params/diff.py index 15688852d..46c541a8c 100644 --- a/dvc/repo/params/diff.py +++ b/dvc/repo/params/diff.py @@ -13,6 +13,12 @@ def diff(repo, *args, a_rev=None, b_rev=None, **kwargs): params = repo.params.show(*args, **kwargs, revs=[a_rev, b_rev]) + # workspace may have been replaced by active branch + workspace_rev = (a_rev == "workspace") or (b_rev == "workspace") + if workspace_rev and "workspace" not in params: + active_branch = repo.scm.active_branch() + params["workspace"] = params[active_branch] + old = params.get(a_rev, {}).get("data", {}) new = params.get(b_rev, {}).get("data", {}) diff --git a/tests/func/params/test_diff.py b/tests/func/params/test_diff.py index ba181ba38..c694e7a43 100644 --- a/tests/func/params/test_diff.py +++ b/tests/func/params/test_diff.py @@ -268,3 +268,11 @@ def test_diff_top_level_params(tmp_dir, dvc, scm, dvcfile, params_file): "foo": {"diff": 2, "new": 5, "old": 3} } } + + +def test_diff_active_branch_no_changes(tmp_dir, scm, dvc): + tmp_dir.gen("params.yaml", "foo: bar") + dvc.run(cmd="echo params.yaml", params=["foo"], single_stage=True) + scm.add(["params.yaml", "Dvcfile"]) + scm.commit("bar") + assert dvc.params.diff(a_rev=tmp_dir.scm.active_branch()) == {}