diff --git a/project.py b/project.py index 142258e4..cdb61c21 100644 --- a/project.py +++ b/project.py @@ -1258,13 +1258,18 @@ class Project(object): elif self.manifest.default.sync_c: 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 (ID_RE.match(self.revisionExpr) and self._CheckForSha1())) if (need_to_fetch and not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, current_branch_only=current_branch_only, - no_tags=no_tags, prune=prune)): + no_tags=no_tags, prune=prune, depth=depth)): return False if self.worktree: @@ -1880,23 +1885,17 @@ class Project(object): quiet=False, alt_dir=None, no_tags=False, - prune=False): + prune=False, + depth=None): is_sha1 = False tag_name = None - depth = None - # The depth should not be used when fetching to a mirror because # it will result in a shallow repository that cannot be cloned or # fetched from. - if not self.manifest.IsMirror: - if self.clone_depth: - depth = self.clone_depth - 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 + # The repo project should also never be synced with partial depth. + if self.manifest.IsMirror or self.relpath == '.repo/repo': + depth = None if depth: current_branch_only = True @@ -2057,21 +2056,22 @@ class Project(object): os.remove(packed_refs) 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 # got what we wanted, else trigger a second run of all # refs. if not self._CheckForSha1(): - if not depth: - # Avoid infinite recursion when depth is True (since depth implies - # 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 + if current_branch_only and depth: + # Sync the current branch only with depth set to None return self._RemoteFetch(name=name, 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