dvc: optimize Git.is_tracked()

Closes #3000
This commit is contained in:
Alexander Schepanovski
2020-01-04 11:32:16 +07:00
parent 85c35f894c
commit a19deb2076
+2 -1
View File
@@ -229,7 +229,8 @@ class Git(Base):
# it is equivalent to `bool(self.repo.git.ls_files(path))` by
# functionality, but ls_files fails on unicode filenames
path = relpath(path, self.root_dir)
return path in [i[0] for i in self.repo.index.entries]
# There are 4 stages, see BaseIndexEntry.stage
return any((path, i) in self.repo.index.entries for i in (0, 1, 2, 3))
def is_dirty(self):
return self.repo.is_dirty()