mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Merge "Fix checkout error when depth passed to repo init and revision is a sha1"
This commit is contained in:
commit
8e2d1d521e
42
project.py
42
project.py
@ -1264,13 +1264,18 @@ class Project(object):
|
|||||||
elif self.manifest.default.sync_c:
|
elif self.manifest.default.sync_c:
|
||||||
current_branch_only = True
|
current_branch_only = True
|
||||||
|
|
||||||
|
if self.clone_depth:
|
||||||
|
depth = self.clone_depth
|
||||||
|
else:
|
||||||
|
depth = self.manifest.manifestProject.config.GetString('repo.depth')
|
||||||
|
|
||||||
need_to_fetch = not (optimized_fetch and
|
need_to_fetch = not (optimized_fetch and
|
||||||
(ID_RE.match(self.revisionExpr) and
|
(ID_RE.match(self.revisionExpr) and
|
||||||
self._CheckForSha1()))
|
self._CheckForSha1()))
|
||||||
if (need_to_fetch and
|
if (need_to_fetch and
|
||||||
not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
|
not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
|
||||||
current_branch_only=current_branch_only,
|
current_branch_only=current_branch_only,
|
||||||
no_tags=no_tags, prune=prune)):
|
no_tags=no_tags, prune=prune, depth=depth)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.worktree:
|
if self.worktree:
|
||||||
@ -1886,23 +1891,17 @@ class Project(object):
|
|||||||
quiet=False,
|
quiet=False,
|
||||||
alt_dir=None,
|
alt_dir=None,
|
||||||
no_tags=False,
|
no_tags=False,
|
||||||
prune=False):
|
prune=False,
|
||||||
|
depth=None):
|
||||||
|
|
||||||
is_sha1 = False
|
is_sha1 = False
|
||||||
tag_name = None
|
tag_name = None
|
||||||
depth = None
|
|
||||||
|
|
||||||
# The depth should not be used when fetching to a mirror because
|
# The depth should not be used when fetching to a mirror because
|
||||||
# it will result in a shallow repository that cannot be cloned or
|
# it will result in a shallow repository that cannot be cloned or
|
||||||
# fetched from.
|
# fetched from.
|
||||||
if not self.manifest.IsMirror:
|
# The repo project should also never be synced with partial depth.
|
||||||
if self.clone_depth:
|
if self.manifest.IsMirror or self.relpath == '.repo/repo':
|
||||||
depth = self.clone_depth
|
depth = None
|
||||||
else:
|
|
||||||
depth = self.manifest.manifestProject.config.GetString('repo.depth')
|
|
||||||
# The repo project should never be synced with partial depth
|
|
||||||
if self.relpath == '.repo/repo':
|
|
||||||
depth = None
|
|
||||||
|
|
||||||
if depth:
|
if depth:
|
||||||
current_branch_only = True
|
current_branch_only = True
|
||||||
@ -2063,21 +2062,22 @@ class Project(object):
|
|||||||
os.remove(packed_refs)
|
os.remove(packed_refs)
|
||||||
self.bare_git.pack_refs('--all', '--prune')
|
self.bare_git.pack_refs('--all', '--prune')
|
||||||
|
|
||||||
if is_sha1 and current_branch_only and self.upstream:
|
if is_sha1 and current_branch_only:
|
||||||
# We just synced the upstream given branch; verify we
|
# We just synced the upstream given branch; verify we
|
||||||
# got what we wanted, else trigger a second run of all
|
# got what we wanted, else trigger a second run of all
|
||||||
# refs.
|
# refs.
|
||||||
if not self._CheckForSha1():
|
if not self._CheckForSha1():
|
||||||
if not depth:
|
if current_branch_only and depth:
|
||||||
# Avoid infinite recursion when depth is True (since depth implies
|
# Sync the current branch only with depth set to None
|
||||||
# current_branch_only)
|
|
||||||
return self._RemoteFetch(name=name, current_branch_only=False,
|
|
||||||
initial=False, quiet=quiet, alt_dir=alt_dir)
|
|
||||||
if self.clone_depth:
|
|
||||||
self.clone_depth = None
|
|
||||||
return self._RemoteFetch(name=name,
|
return self._RemoteFetch(name=name,
|
||||||
current_branch_only=current_branch_only,
|
current_branch_only=current_branch_only,
|
||||||
initial=False, quiet=quiet, alt_dir=alt_dir)
|
initial=False, quiet=quiet, alt_dir=alt_dir,
|
||||||
|
depth=None)
|
||||||
|
else:
|
||||||
|
# Avoid infinite recursion: sync all branches with depth set to None
|
||||||
|
return self._RemoteFetch(name=name, current_branch_only=False,
|
||||||
|
initial=False, quiet=quiet, alt_dir=alt_dir,
|
||||||
|
depth=None)
|
||||||
|
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user