Revert "git_cache: Remove locks"

This reverts commit c3eb3fa33551c957d0179472c908864da016d95a.

Reason for revert: lots of "runhooks" failure everywhere

Example: https://build.chromium.org/p/chromium.linux/builders/Linux%20Builder/builds/92720

Original change's description:
> git_cache: Remove locks
> 
> These aren't in use, and the original problem they were
> meant to solve has been solved at the gclient.py layer 
> using resource locking:
>   https://codereview.chromium.org/2049583003
> 
> Bug: 773008
> Change-Id: I6609f39d7f15604e0bb3d742a41c4f9fec87a57a
> Reviewed-on: https://chromium-review.googlesource.com/707728
> Reviewed-by: Aaron Gable <agable@chromium.org>
> Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
> Commit-Queue: Ryan Tseng <hinoka@chromium.org>

TBR=iannucci@chromium.org,hinoka@chromium.org,agable@chromium.org,phajdan.jr@chromium.org

Change-Id: I31d5fef94f39f3a9f97b9e59121073b1f433d11e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 773008
Reviewed-on: https://chromium-review.googlesource.com/711054
Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
diff --git a/gclient.py b/gclient.py
index 76832f2..adedd61 100755
--- a/gclient.py
+++ b/gclient.py
@@ -1308,6 +1308,10 @@
     if cache_dir:
       cache_dir = os.path.join(self.root_dir, cache_dir)
       cache_dir = os.path.abspath(cache_dir)
+      # If running on a bot, force break any stale git cache locks.
+      if os.path.exists(cache_dir) and os.environ.get('CHROME_HEADLESS'):
+        subprocess2.check_call(['git', 'cache', 'unlock', '--cache-dir',
+                                cache_dir, '--force', '--all'])
     gclient_scm.GitWrapper.cache_dir = cache_dir
     git_cache.Mirror.SetCachePath(cache_dir)
 
@@ -2350,11 +2354,16 @@
   parser.add_option('--no_bootstrap', '--no-bootstrap',
                     action='store_true',
                     help='Don\'t bootstrap from Google Storage.')
+  parser.add_option('--ignore_locks', action='store_true',
+                    help='GIT ONLY - Ignore cache locks.')
   parser.add_option('--break_repo_locks', action='store_true',
                     help='GIT ONLY - Forcibly remove repo locks (e.g. '
                       'index.lock). This should only be used if you know for '
                       'certain that this invocation of gclient is the only '
                       'thing operating on the git repos (e.g. on a bot).')
+  parser.add_option('--lock_timeout', type='int', default=5000,
+                    help='GIT ONLY - Deadline (in seconds) to wait for git '
+                         'cache lock to become available. Default is %default.')
   # TODO(agable): Remove these when the oldest CrOS release milestone is M56.
   parser.add_option('-t', '--transitive', action='store_true',
                     help='DEPRECATED: This is a no-op.')