Skip to content

Commit 90152ea

Browse files
authored
Merge pull request #3053 from Suor/is-tracked
dvc: optimize Git.is_tracked()
2 parents 095464d + a19deb2 commit 90152ea

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dvc/scm/git/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def is_tracked(self, path):
229229
# it is equivalent to `bool(self.repo.git.ls_files(path))` by
230230
# functionality, but ls_files fails on unicode filenames
231231
path = relpath(path, self.root_dir)
232-
return path in [i[0] for i in self.repo.index.entries]
232+
# There are 4 stages, see BaseIndexEntry.stage
233+
return any((path, i) in self.repo.index.entries for i in (0, 1, 2, 3))
233234

234235
def is_dirty(self):
235236
return self.repo.is_dirty()

0 commit comments

Comments
 (0)