summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2015-08-03 13:11:53 -0700
committerDan Willemsen <dwillemsen@google.com>2015-08-03 16:54:16 -0700
commiteeab6860f1c5e542ebabdec2e44185bedad49ed7 (patch)
treeaf793b69bd9939ecbc42d390605c721e6ca97c08 /project.py
parent163fdbf2fd6ac8bb1f1e41fb74e68261badce32d (diff)
downloadgit-repo-eeab6860f1c5e542ebabdec2e44185bedad49ed7.tar.gz
Fix shallow clone behavior
The existing code here makes sure that switching clone-depth from on to off actually causes the history to be fully restored. Unfortunately, it does this by fetching the full history every time the fetch spec changes. Switching between two clone-depth="1" branches will fetch far more than the top commit. Instead, when not using clone-depth, pass --depth=2147483647 to git fetch so that it ensures that we have the entire history. That is slightly less efficient, so limit it to only when there are shallow objects in the project by checking for the existance of the 'shallow' file. Change-Id: Iee0cfc9c6992c208344b1d9123769992412db67b
Diffstat (limited to 'project.py')
-rw-r--r--project.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/project.py b/project.py
index 9cb7542e..a117f4df 100644
--- a/project.py
+++ b/project.py
@@ -1877,6 +1877,13 @@ class Project(object):
1877 1877
1878 if depth: 1878 if depth:
1879 cmd.append('--depth=%s' % depth) 1879 cmd.append('--depth=%s' % depth)
1880 else:
1881 # If this repo has shallow objects, then we don't know which refs have
1882 # shallow objects or not. Tell git to unshallow all fetched refs. Don't
1883 # do this with projects that don't have shallow objects, since it is less
1884 # efficient.
1885 if os.path.exists(os.path.join(self.gitdir, 'shallow')):
1886 cmd.append('--depth=2147483647')
1880 1887
1881 if quiet: 1888 if quiet:
1882 cmd.append('--quiet') 1889 cmd.append('--quiet')
@@ -1914,16 +1921,6 @@ class Project(object):
1914 spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch))) 1921 spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch)))
1915 cmd.extend(spec) 1922 cmd.extend(spec)
1916 1923
1917 shallowfetch = self.config.GetString('repo.shallowfetch')
1918 if shallowfetch and shallowfetch != ' '.join(spec):
1919 GitCommand(self, ['fetch', '--depth=2147483647', name]
1920 + shallowfetch.split(),
1921 bare=True, ssh_proxy=ssh_proxy).Wait()
1922 if depth:
1923 self.config.SetString('repo.shallowfetch', ' '.join(spec))
1924 else:
1925 self.config.SetString('repo.shallowfetch', None)
1926
1927 ok = False 1924 ok = False
1928 for _i in range(2): 1925 for _i in range(2):
1929 gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy) 1926 gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy)