From 69e04d89538e4a253efe7d9f4fd1f1ae70f8f62c Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Wed, 29 Jan 2014 12:48:54 -0800 Subject: [PATCH] Only fetch current branch on shallow clients Fetching a new branch on a shallow client may download the entire project history, as the depth parameter is not passed to git fetch. Force the fetch to only download the current branch. Change-Id: Ie17ce8eb5e3487c24d90b2cae8227319dea482c8 --- project.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/project.py b/project.py index dec21ab1..a6a88607 100644 --- a/project.py +++ b/project.py @@ -1593,6 +1593,13 @@ class Project(object): # There is no such persistent revision. We have to fetch it. return False + if self.clone_depth: + depth = self.clone_depth + else: + depth = self.manifest.manifestProject.config.GetString('repo.depth') + if depth: + current_branch_only = True + if current_branch_only: if ID_RE.match(self.revisionExpr) is not None: is_sha1 = True @@ -1656,10 +1663,6 @@ class Project(object): # The --depth option only affects the initial fetch; after that we'll do # full fetches of changes. - if self.clone_depth: - depth = self.clone_depth - else: - depth = self.manifest.manifestProject.config.GetString('repo.depth') if depth and initial: cmd.append('--depth=%s' % depth)