mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
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
This commit is contained in:
parent
163fdbf2fd
commit
eeab6860f1
17
project.py
17
project.py
@ -1877,6 +1877,13 @@ class Project(object):
|
|||||||
|
|
||||||
if depth:
|
if depth:
|
||||||
cmd.append('--depth=%s' % depth)
|
cmd.append('--depth=%s' % depth)
|
||||||
|
else:
|
||||||
|
# If this repo has shallow objects, then we don't know which refs have
|
||||||
|
# shallow objects or not. Tell git to unshallow all fetched refs. Don't
|
||||||
|
# do this with projects that don't have shallow objects, since it is less
|
||||||
|
# efficient.
|
||||||
|
if os.path.exists(os.path.join(self.gitdir, 'shallow')):
|
||||||
|
cmd.append('--depth=2147483647')
|
||||||
|
|
||||||
if quiet:
|
if quiet:
|
||||||
cmd.append('--quiet')
|
cmd.append('--quiet')
|
||||||
@ -1914,16 +1921,6 @@ class Project(object):
|
|||||||
spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch)))
|
spec.append(str((u'+%s:' % branch) + remote.ToLocal(branch)))
|
||||||
cmd.extend(spec)
|
cmd.extend(spec)
|
||||||
|
|
||||||
shallowfetch = self.config.GetString('repo.shallowfetch')
|
|
||||||
if shallowfetch and shallowfetch != ' '.join(spec):
|
|
||||||
GitCommand(self, ['fetch', '--depth=2147483647', name]
|
|
||||||
+ shallowfetch.split(),
|
|
||||||
bare=True, ssh_proxy=ssh_proxy).Wait()
|
|
||||||
if depth:
|
|
||||||
self.config.SetString('repo.shallowfetch', ' '.join(spec))
|
|
||||||
else:
|
|
||||||
self.config.SetString('repo.shallowfetch', None)
|
|
||||||
|
|
||||||
ok = False
|
ok = False
|
||||||
for _i in range(2):
|
for _i in range(2):
|
||||||
gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy)
|
gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy)
|
||||||
|
Loading…
Reference in New Issue
Block a user