[gclient_scm] Update _CheckClean() to use `git status`

This change updates the `_CheckClean()` fn to use `git status` instead
of `git update-index` and `git diff-index`. The `_CheckClean()` fn is
run during every update and this change reduces the subprocess calls
made by it by half.

Change-Id: Ie9a23b0bce748bec4cac88df09655569e88e4841
Bug: 1501984
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5076224
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
diff --git a/gclient_scm.py b/gclient_scm.py
index 18811c4..574da8c 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -1422,28 +1422,15 @@
                 '\tIf no git executable is running, then clean up %r and try again.\n'
                 % (self.relpath, revision, lockfile))
 
-        # Make sure the tree is clean; see git-rebase.sh for reference
-        try:
-            scm.GIT.Capture(
-                ['update-index', '--ignore-submodules', '--refresh'],
-                cwd=self.checkout_path)
-        except subprocess2.CalledProcessError:
+        # Ensure that the tree is clean.
+        if scm.GIT.Capture([
+                'status', '--porcelain', '--untracked-files=no',
+                '--ignore-submodules'
+        ],
+                           cwd=self.checkout_path):
             raise gclient_utils.Error(
                 '\n____ %s at %s\n'
-                '\tYou have unstaged changes.\n'
-                '\tcd into %s, run git status to see changes,\n'
-                '\tand commit, stash, or reset.\n' %
-                (self.relpath, revision, self.relpath))
-        try:
-            scm.GIT.Capture([
-                'diff-index', '--cached', '--name-status', '-r',
-                '--ignore-submodules', 'HEAD', '--'
-            ],
-                            cwd=self.checkout_path)
-        except subprocess2.CalledProcessError:
-            raise gclient_utils.Error(
-                '\n____ %s at %s\n'
-                '\tYour index contains uncommitted changes\n'
+                '\tYou have uncommitted changes.\n'
                 '\tcd into %s, run git status to see changes,\n'
                 '\tand commit, stash, or reset.\n' %
                 (self.relpath, revision, self.relpath))