summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'project.py')
-rw-r--r--project.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/project.py b/project.py
index f514af77..49db02e3 100644
--- a/project.py
+++ b/project.py
@@ -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')