summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--project.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/project.py b/project.py
index cdce1e84..b9a53dce 100644
--- a/project.py
+++ b/project.py
@@ -1763,8 +1763,15 @@ class Project(object):
1763 if is_sha1 or tag_name is not None: 1763 if is_sha1 or tag_name is not None:
1764 if self._CheckForSha1(): 1764 if self._CheckForSha1():
1765 return True 1765 return True
1766 if is_sha1 and (not self.upstream or ID_RE.match(self.upstream)): 1766 if is_sha1 and not depth:
1767 current_branch_only = False 1767 # When syncing a specific commit and --depth is not set:
1768 # * if upstream is explicitly specified and is not a sha1, fetch only
1769 # upstream as users expect only upstream to be fetch.
1770 # Note: The commit might not be in upstream in which case the sync
1771 # will fail.
1772 # * otherwise, fetch all branches to make sure we end up with the
1773 # specific commit.
1774 current_branch_only = self.upstream and not ID_RE.match(self.upstream)
1768 1775
1769 if not name: 1776 if not name:
1770 name = self.remote.name 1777 name = self.remote.name
@@ -1841,12 +1848,17 @@ class Project(object):
1841 spec.append(tag_name) 1848 spec.append(tag_name)
1842 1849
1843 branch = self.revisionExpr 1850 branch = self.revisionExpr
1844 if is_sha1: 1851 if is_sha1 and depth:
1845 branch = self.upstream 1852 # Shallow checkout of a specific commit, fetch from that commit and not
1846 if branch is not None and branch.strip(): 1853 # the heads only as the commit might be deeper in the history.
1847 if not branch.startswith('refs/'): 1854 spec.append(branch)
1848 branch = R_HEADS + branch 1855 else:
1849 spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch))) 1856 if is_sha1:
1857 branch = self.upstream
1858 if branch is not None and branch.strip():
1859 if not branch.startswith('refs/'):
1860 branch = R_HEADS + branch
1861 spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch)))
1850 cmd.extend(spec) 1862 cmd.extend(spec)
1851 1863
1852 shallowfetch = self.config.GetString('repo.shallowfetch') 1864 shallowfetch = self.config.GetString('repo.shallowfetch')