From 01653b80774688a8ae2acbf5b2c535eca4840273 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 7 Jul 2019 22:10:32 -0700 Subject: [PATCH] Fix shallow fetch by checking out FETCH_HEAD --- pre_commit/store.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pre_commit/store.py b/pre_commit/store.py index d1d432dc..08733ab8 100644 --- a/pre_commit/store.py +++ b/pre_commit/store.py @@ -142,15 +142,15 @@ class Store(object): git_cmd('checkout', ref) git_cmd('submodule', 'update', '--init', '--recursive') - def _shallow_clone(self, ref, git_cmd): # pragma: windows no cover + def _shallow_clone(self, ref, git_cmd): """Perform a shallow clone of a repository and its submodules """ git_config = 'protocol.version=2' git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1') - git_cmd('checkout', ref) + git_cmd('checkout', 'FETCH_HEAD') git_cmd( - '-c', git_config, 'submodule', 'update', '--init', - '--recursive', '--depth=1', + '-c', git_config, 'submodule', 'update', '--init', '--recursive', + '--depth=1', ) def clone(self, repo, ref, deps=()):