diff: handle revisions pointing to the same sha

Fixes #9604
This commit is contained in:
Ruslan Kuprieiev
2023-06-14 18:48:18 +03:00
parent 97348cfba7
commit a6e49a72de
2 changed files with 15 additions and 2 deletions
+7 -2
View File
@@ -156,8 +156,13 @@ def diff(
for target in old_missing & new_missing:
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), target)
old = indexes[a_rev]
new = indexes[b_rev]
if len(indexes.keys()) == 1:
# both a_rev and b_rev point to the same sha, nothing to compare
old = None
new = None
else:
old = indexes[a_rev]
new = indexes[b_rev]
with ui.status("Calculating diff"):
return _diff(old, new, with_missing=with_missing)
+8
View File
@@ -21,6 +21,14 @@ def test_no_scm(tmp_dir, dvc):
dvc.diff()
def test_same_rev(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("file", "text", commit="add file")
assert not dvc.diff("HEAD", "HEAD")
assert not dvc.diff("HEAD", "master")
assert not dvc.diff("master", "HEAD")
def test_added(tmp_dir, scm, dvc):
tmp_dir.dvc_gen("file", "text")