Repository: iterative/dvc

Issue:
Speed up dvc status for large projects
**Please provide information about your setup**
DVC version(i.e. `dvc --version`), Platform and method of installation (pip, homebrew, pkg Mac, exe (Windows), DEB(Linux), RPM(Linux))

```
dvc version

DVC version: 0.82.8
Python version: 3.7.6
Platform: Linux-5.0.0-37-generic-x86_64-with-debian-buster-sid
Binary: False
Package: pip
Cache: reflink - not supported, hardlink - not supported, symlink - supported
Filesystem type (cache directory): ('ext4', '/dev/sda1')
Filesystem type (workspace): ('ext4', '/dev/nvme0n1p2')
```

expect `dvc status` can return in a shorter time, currently it takes 30s.

a few stats
```
du -shL my-project # 107G
```

```
dvc status -v
```
[log.txt](https://github.com/iterative/dvc/files/4153107/log.txt)


Discussion:

Patch:
diff --git a/dvc/external_repo.py b/dvc/external_repo.py
index 9ea0d62e2..6bb34f4b5 100644
--- a/dvc/external_repo.py
+++ b/dvc/external_repo.py
@@ -200,7 +200,7 @@ def _clone_default_branch(url, rev):
         if clone_path:
             git = Git(clone_path)
             # Do not pull for known shas, branches and tags might move
-            if not Git.is_sha(rev) or not git.is_known(rev):
+            if not Git.is_sha(rev) or not git.has_rev(rev):
                 git.pull()
         else:
             clone_path = tempfile.mkdtemp("dvc-clone")


Test patch:
diff --git a/tests/func/test_external_repo.py b/tests/func/test_external_repo.py
index 8c5b9df35..46103fbb8 100644
--- a/tests/func/test_external_repo.py
+++ b/tests/func/test_external_repo.py
@@ -56,3 +56,18 @@ def test_cache_reused(erepo_dir, mocker):
     with external_repo(url, "branch") as repo:
         repo.fetch()
         assert download_spy.mock.call_count == 1
+
+
+def test_known_sha(erepo_dir):
+    url = "file://{}".format(erepo_dir)
+    with external_repo(url) as repo:
+        rev = repo.scm.get_rev()
+        prev_rev = repo.scm.resolve_rev("HEAD^")
+
+    # Hits cache
+    with external_repo(url, rev) as repo:
+        pass
+
+    # No clone, no pull, copies a repo, checks out the known sha
+    with external_repo(url, prev_rev) as repo:
+        pass