Skip to content

Commit 01653b8

Browse files
committed
Fix shallow fetch by checking out FETCH_HEAD
1 parent 0cf2638 commit 01653b8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pre_commit/store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ def _complete_clone(self, ref, git_cmd):
142142
git_cmd('checkout', ref)
143143
git_cmd('submodule', 'update', '--init', '--recursive')
144144

145-
def _shallow_clone(self, ref, git_cmd): # pragma: windows no cover
145+
def _shallow_clone(self, ref, git_cmd):
146146
"""Perform a shallow clone of a repository and its submodules """
147147

148148
git_config = 'protocol.version=2'
149149
git_cmd('-c', git_config, 'fetch', 'origin', ref, '--depth=1')
150-
git_cmd('checkout', ref)
150+
git_cmd('checkout', 'FETCH_HEAD')
151151
git_cmd(
152-
'-c', git_config, 'submodule', 'update', '--init',
153-
'--recursive', '--depth=1',
152+
'-c', git_config, 'submodule', 'update', '--init', '--recursive',
153+
'--depth=1',
154154
)
155155

156156
def clone(self, repo, ref, deps=()):

0 commit comments

Comments
 (0)