diff options
author | Aymen Bouaziz <aymen.bouaziz@parrot.com> | 2016-10-25 18:03:51 +0200 |
---|---|---|
committer | Aymen Bouaziz <aymen.bouaziz@parrot.com> | 2016-10-28 14:29:57 +0200 |
commit | 6c5944606af3c52626745b5256e9e5f0d5c362a2 (patch) | |
tree | a34387f91d0a67c01455c2a211ae5401fe5a2bda /project.py | |
parent | eceeb1b1f5edb0f42e690bffdf81828abd8ea7fe (diff) | |
download | git-repo-6c5944606af3c52626745b5256e9e5f0d5c362a2.tar.gz |
Fix checkout error when depth passed to repo init and revision is a sha1
Currently, if direct fetch of a sha1 is not supported by git server and
depth option is used, we fallback on syncing the upstream branch by
ignoring depth option.
This fallback doesn't work in next 2 cases:
(1) upstream attribute is not specified in manifest
(2) depth option is passed to repo init command
(not with clone-depth attribute in manifest)
This commit do the following:
- fixes (1) by updating condition used to apply fallback
first we retry with depth set to None, then by syncing all branches
- fixes (2) by passing depth as argument of _RemoteFetch() method
thus, its value is not set again to depth value passed to repo init
command when applying fallback
Change-Id: Ifd6fffafc49ba229df624b0d7b64c83d47619d17
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -1258,13 +1258,18 @@ class Project(object): | |||
1258 | elif self.manifest.default.sync_c: | 1258 | elif self.manifest.default.sync_c: |
1259 | current_branch_only = True | 1259 | current_branch_only = True |
1260 | 1260 | ||
1261 | if self.clone_depth: | ||
1262 | depth = self.clone_depth | ||
1263 | else: | ||
1264 | depth = self.manifest.manifestProject.config.GetString('repo.depth') | ||
1265 | |||
1261 | need_to_fetch = not (optimized_fetch and | 1266 | need_to_fetch = not (optimized_fetch and |
1262 | (ID_RE.match(self.revisionExpr) and | 1267 | (ID_RE.match(self.revisionExpr) and |
1263 | self._CheckForSha1())) | 1268 | self._CheckForSha1())) |
1264 | if (need_to_fetch and | 1269 | if (need_to_fetch and |
1265 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, | 1270 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, |
1266 | current_branch_only=current_branch_only, | 1271 | current_branch_only=current_branch_only, |
1267 | no_tags=no_tags, prune=prune)): | 1272 | no_tags=no_tags, prune=prune, depth=depth)): |
1268 | return False | 1273 | return False |
1269 | 1274 | ||
1270 | if self.worktree: | 1275 | if self.worktree: |
@@ -1880,23 +1885,17 @@ class Project(object): | |||
1880 | quiet=False, | 1885 | quiet=False, |
1881 | alt_dir=None, | 1886 | alt_dir=None, |
1882 | no_tags=False, | 1887 | no_tags=False, |
1883 | prune=False): | 1888 | prune=False, |
1889 | depth=None): | ||
1884 | 1890 | ||
1885 | is_sha1 = False | 1891 | is_sha1 = False |
1886 | tag_name = None | 1892 | tag_name = None |
1887 | depth = None | ||
1888 | |||
1889 | # The depth should not be used when fetching to a mirror because | 1893 | # The depth should not be used when fetching to a mirror because |
1890 | # it will result in a shallow repository that cannot be cloned or | 1894 | # it will result in a shallow repository that cannot be cloned or |
1891 | # fetched from. | 1895 | # fetched from. |
1892 | if not self.manifest.IsMirror: | 1896 | # The repo project should also never be synced with partial depth. |
1893 | if self.clone_depth: | 1897 | if self.manifest.IsMirror or self.relpath == '.repo/repo': |
1894 | depth = self.clone_depth | 1898 | depth = None |
1895 | else: | ||
1896 | depth = self.manifest.manifestProject.config.GetString('repo.depth') | ||
1897 | # The repo project should never be synced with partial depth | ||
1898 | if self.relpath == '.repo/repo': | ||
1899 | depth = None | ||
1900 | 1899 | ||
1901 | if depth: | 1900 | if depth: |
1902 | current_branch_only = True | 1901 | current_branch_only = True |
@@ -2057,21 +2056,22 @@ class Project(object): | |||
2057 | os.remove(packed_refs) | 2056 | os.remove(packed_refs) |
2058 | self.bare_git.pack_refs('--all', '--prune') | 2057 | self.bare_git.pack_refs('--all', '--prune') |
2059 | 2058 | ||
2060 | if is_sha1 and current_branch_only and self.upstream: | 2059 | if is_sha1 and current_branch_only: |
2061 | # We just synced the upstream given branch; verify we | 2060 | # We just synced the upstream given branch; verify we |
2062 | # got what we wanted, else trigger a second run of all | 2061 | # got what we wanted, else trigger a second run of all |
2063 | # refs. | 2062 | # refs. |
2064 | if not self._CheckForSha1(): | 2063 | if not self._CheckForSha1(): |
2065 | if not depth: | 2064 | if current_branch_only and depth: |
2066 | # Avoid infinite recursion when depth is True (since depth implies | 2065 | # Sync the current branch only with depth set to None |
2067 | # current_branch_only) | ||
2068 | return self._RemoteFetch(name=name, current_branch_only=False, | ||
2069 | initial=False, quiet=quiet, alt_dir=alt_dir) | ||
2070 | if self.clone_depth: | ||
2071 | self.clone_depth = None | ||
2072 | return self._RemoteFetch(name=name, | 2066 | return self._RemoteFetch(name=name, |
2073 | current_branch_only=current_branch_only, | 2067 | current_branch_only=current_branch_only, |
2074 | initial=False, quiet=quiet, alt_dir=alt_dir) | 2068 | initial=False, quiet=quiet, alt_dir=alt_dir, |
2069 | depth=None) | ||
2070 | else: | ||
2071 | # Avoid infinite recursion: sync all branches with depth set to None | ||
2072 | return self._RemoteFetch(name=name, current_branch_only=False, | ||
2073 | initial=False, quiet=quiet, alt_dir=alt_dir, | ||
2074 | depth=None) | ||
2075 | 2075 | ||
2076 | return ok | 2076 | return ok |
2077 | 2077 | ||