summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorKevin Degi <kdegi@codeaurora.org>2015-06-22 15:31:26 -0600
committerKevin Degi <kdegi@codeaurora.org>2015-07-15 15:53:14 +0000
commit679bac4bf3622412c29e8bca506bc670224d2e31 (patch)
tree08e61b881facf5795d24b173bf8a2adf69d5db55 /project.py
parent185307d1dd1e63a8cf139c55f26895a6b378d43b (diff)
downloadgit-repo-679bac4bf3622412c29e8bca506bc670224d2e31.tar.gz
project.RemoteFetch: Handle depth cases more robustly
The fetch logic for the case where depth is set and revision is a SHA1 has several failure modes that are not handled well by the current logic. 1) 'git fetch <SHA1>' requires git version >= 1.8.3 2) 'git fetch <SHA1>' can be prevented by a configuration option on the server. 3) 'git fetch --depth=<N> <refspec>' can fail to contain a SHA1 specified by the manifest. Each of these cases cause infinite recursion when _RemoteFetch() tries to call itself with current_branch_only=False because current_branch_only is set to True when depth != None. To try to prevent the infinite recursion, we set self.clone_depth to None before the first retry of _RemoteFetch(). This will allow the Fetch to eventually succeed in the case where clone-depth is specified in the manifest. A user specified depth from the init command will still recurse infinitely. In addition, never try to fetch a SHA1 directly if the git version being used is not at least 1.8.3. Change-Id: I802fc17878c0929cfd63fff611633c1d3b54ecd3
Diffstat (limited to 'project.py')
-rw-r--r--project.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/project.py b/project.py
index 3f1e3b65..2f70e996 100644
--- a/project.py
+++ b/project.py
@@ -1897,7 +1897,7 @@ class Project(object):
1897 1897
1898 if not self.manifest.IsMirror: 1898 if not self.manifest.IsMirror:
1899 branch = self.revisionExpr 1899 branch = self.revisionExpr
1900 if is_sha1 and depth: 1900 if is_sha1 and depth and git_require((1, 8, 3)):
1901 # Shallow checkout of a specific commit, fetch from that commit and not 1901 # Shallow checkout of a specific commit, fetch from that commit and not
1902 # the heads only as the commit might be deeper in the history. 1902 # the heads only as the commit might be deeper in the history.
1903 spec.append(branch) 1903 spec.append(branch)
@@ -1960,8 +1960,15 @@ class Project(object):
1960 # got what we wanted, else trigger a second run of all 1960 # got what we wanted, else trigger a second run of all
1961 # refs. 1961 # refs.
1962 if not self._CheckForSha1(): 1962 if not self._CheckForSha1():
1963 return self._RemoteFetch(name=name, current_branch_only=False, 1963 if not depth:
1964 initial=False, quiet=quiet, alt_dir=alt_dir) 1964 # Avoid infinite recursion when depth is True (since depth implies
1965 # current_branch_only)
1966 return self._RemoteFetch(name=name, current_branch_only=False,
1967 initial=False, quiet=quiet, alt_dir=alt_dir)
1968 if self.clone_depth:
1969 self.clone_depth = None
1970 return self._RemoteFetch(name=name, current_branch_only=current_branch_only,
1971 initial=False, quiet=quiet, alt_dir=alt_dir)
1965 1972
1966 return ok 1973 return ok
1967 1974