mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-04 16:14:25 +00:00
Handle shallow checkout of SHA1 pinned repos
When doing a shallow checkout SHA1 pinned repos with repo init --depth=1 and repo sync -c, repo would try to fetch only some reference and fail if the exact SHA1 repo was missing. Instead, when depth is set, fetch only the specific commit. Change-Id: If3f799d0e78c03faea47f796380bb5e367b11998
This commit is contained in:
parent
3eb87cec5c
commit
3000cdad22
16
project.py
16
project.py
@ -1763,8 +1763,15 @@ class Project(object):
|
|||||||
if is_sha1 or tag_name is not None:
|
if is_sha1 or tag_name is not None:
|
||||||
if self._CheckForSha1():
|
if self._CheckForSha1():
|
||||||
return True
|
return True
|
||||||
if is_sha1 and (not self.upstream or ID_RE.match(self.upstream)):
|
if is_sha1 and not depth:
|
||||||
current_branch_only = False
|
# When syncing a specific commit and --depth is not set:
|
||||||
|
# * if upstream is explicitly specified and is not a sha1, fetch only
|
||||||
|
# upstream as users expect only upstream to be fetch.
|
||||||
|
# Note: The commit might not be in upstream in which case the sync
|
||||||
|
# will fail.
|
||||||
|
# * otherwise, fetch all branches to make sure we end up with the
|
||||||
|
# specific commit.
|
||||||
|
current_branch_only = self.upstream and not ID_RE.match(self.upstream)
|
||||||
|
|
||||||
if not name:
|
if not name:
|
||||||
name = self.remote.name
|
name = self.remote.name
|
||||||
@ -1841,6 +1848,11 @@ class Project(object):
|
|||||||
spec.append(tag_name)
|
spec.append(tag_name)
|
||||||
|
|
||||||
branch = self.revisionExpr
|
branch = self.revisionExpr
|
||||||
|
if is_sha1 and depth:
|
||||||
|
# Shallow checkout of a specific commit, fetch from that commit and not
|
||||||
|
# the heads only as the commit might be deeper in the history.
|
||||||
|
spec.append(branch)
|
||||||
|
else:
|
||||||
if is_sha1:
|
if is_sha1:
|
||||||
branch = self.upstream
|
branch = self.upstream
|
||||||
if branch is not None and branch.strip():
|
if branch is not None and branch.strip():
|
||||||
|
Loading…
Reference in New Issue
Block a user