diff options
| author | Conley Owens <cco3@android.com> | 2015-01-28 20:29:37 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-01-28 20:29:37 +0000 |
| commit | ee6908442102008df57b46271323d9b06d5fdfbf (patch) | |
| tree | 27cec0e64125fc04c4286f315f3682c1d2ded0f1 | |
| parent | d37d43f036dfbbdee6a3979b73d1dce3d3b96e19 (diff) | |
| parent | 3000cdad2237abe1f956f8109e385891e1a96d17 (diff) | |
| download | git-repo-ee6908442102008df57b46271323d9b06d5fdfbf.tar.gz | |
Merge "Handle shallow checkout of SHA1 pinned repos"
| -rw-r--r-- | project.py | 28 |
1 files changed, 20 insertions, 8 deletions
| @@ -1764,8 +1764,15 @@ class Project(object): | |||
| 1764 | if is_sha1 or tag_name is not None: | 1764 | if is_sha1 or tag_name is not None: |
| 1765 | if self._CheckForSha1(): | 1765 | if self._CheckForSha1(): |
| 1766 | return True | 1766 | return True |
| 1767 | if is_sha1 and (not self.upstream or ID_RE.match(self.upstream)): | 1767 | if is_sha1 and not depth: |
| 1768 | current_branch_only = False | 1768 | # When syncing a specific commit and --depth is not set: |
| 1769 | # * if upstream is explicitly specified and is not a sha1, fetch only | ||
| 1770 | # upstream as users expect only upstream to be fetch. | ||
| 1771 | # Note: The commit might not be in upstream in which case the sync | ||
| 1772 | # will fail. | ||
| 1773 | # * otherwise, fetch all branches to make sure we end up with the | ||
| 1774 | # specific commit. | ||
| 1775 | current_branch_only = self.upstream and not ID_RE.match(self.upstream) | ||
| 1769 | 1776 | ||
| 1770 | if not name: | 1777 | if not name: |
| 1771 | name = self.remote.name | 1778 | name = self.remote.name |
| @@ -1842,12 +1849,17 @@ class Project(object): | |||
| 1842 | spec.append(tag_name) | 1849 | spec.append(tag_name) |
| 1843 | 1850 | ||
| 1844 | branch = self.revisionExpr | 1851 | branch = self.revisionExpr |
| 1845 | if is_sha1: | 1852 | if is_sha1 and depth: |
| 1846 | branch = self.upstream | 1853 | # Shallow checkout of a specific commit, fetch from that commit and not |
| 1847 | if branch is not None and branch.strip(): | 1854 | # the heads only as the commit might be deeper in the history. |
| 1848 | if not branch.startswith('refs/'): | 1855 | spec.append(branch) |
| 1849 | branch = R_HEADS + branch | 1856 | else: |
| 1850 | spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch))) | 1857 | if is_sha1: |
| 1858 | branch = self.upstream | ||
| 1859 | if branch is not None and branch.strip(): | ||
| 1860 | if not branch.startswith('refs/'): | ||
| 1861 | branch = R_HEADS + branch | ||
| 1862 | spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch))) | ||
| 1851 | cmd.extend(spec) | 1863 | cmd.extend(spec) |
| 1852 | 1864 | ||
| 1853 | shallowfetch = self.config.GetString('repo.shallowfetch') | 1865 | shallowfetch = self.config.GetString('repo.shallowfetch') |
