From 7c1e339650c0ebbdb9c37e697b79753d8c1774dd Mon Sep 17 00:00:00 2001 From: skshetry Date: Tue, 9 Aug 2022 09:34:15 +0545 Subject: [PATCH] data status: handle path joining properly for tree leaves/items (#8107) --- dvc/repo/data.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dvc/repo/data.py b/dvc/repo/data.py index bab312e33..e1929dbc2 100644 --- a/dvc/repo/data.py +++ b/dvc/repo/data.py @@ -68,13 +68,17 @@ def _granular_diff( from dvc_data.diff import diff as odiff from dvc_data.objects.tree import Tree + drop_root = False + trees = isinstance(old_obj, Tree) or isinstance(new_obj, Tree) + if trees: + drop_root = not with_dirs + def path_join(root: str, *paths: str) -> str: - if not isinstance(new_obj, Tree): + if not trees and paths == ROOT: return root return os.path.sep.join([root, *paths]) diff_data = odiff(old_obj, new_obj, cache) - drop_root = not with_dirs and isinstance(new_obj, Tree) output: Dict[str, List[str]] = defaultdict(list) for state in ("added", "deleted", "modified", "unchanged"):