mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Use fetch --unshallow when appropriate.
If a user reinits to a different manifest or the manifest updates so that a project no longer has a fixed depth, we need to use --unshallow when we fetch. Change-Id: I6d3f15e5464b5eaad9205654bc24354947a78aea
This commit is contained in:
parent
e9f75b1782
commit
80b87fe6c1
28
project.py
28
project.py
@ -1706,6 +1706,7 @@ class Project(object):
|
|||||||
if command.Wait() != 0:
|
if command.Wait() != 0:
|
||||||
raise GitError('git archive %s: %s' % (self.name, command.stderr))
|
raise GitError('git archive %s: %s' % (self.name, command.stderr))
|
||||||
|
|
||||||
|
|
||||||
def _RemoteFetch(self, name=None,
|
def _RemoteFetch(self, name=None,
|
||||||
current_branch_only=False,
|
current_branch_only=False,
|
||||||
initial=False,
|
initial=False,
|
||||||
@ -1808,19 +1809,30 @@ class Project(object):
|
|||||||
else:
|
else:
|
||||||
cmd.append('--tags')
|
cmd.append('--tags')
|
||||||
|
|
||||||
|
spec = []
|
||||||
if not current_branch_only:
|
if not current_branch_only:
|
||||||
# Fetch whole repo
|
# Fetch whole repo
|
||||||
cmd.append(str((u'+refs/heads/*:') + remote.ToLocal('refs/heads/*')))
|
spec.append(str((u'+refs/heads/*:') + remote.ToLocal('refs/heads/*')))
|
||||||
elif tag_name is not None:
|
elif tag_name is not None:
|
||||||
cmd.append('tag')
|
spec.append('tag')
|
||||||
cmd.append(tag_name)
|
spec.append(tag_name)
|
||||||
else:
|
else:
|
||||||
branch = self.revisionExpr
|
branch = self.revisionExpr
|
||||||
if is_sha1:
|
if is_sha1:
|
||||||
branch = self.upstream
|
branch = self.upstream
|
||||||
if branch.startswith(R_HEADS):
|
if branch.startswith(R_HEADS):
|
||||||
branch = branch[len(R_HEADS):]
|
branch = branch[len(R_HEADS):]
|
||||||
cmd.append(str((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch)))
|
spec.append(str((u'+refs/heads/%s:' % branch) + remote.ToLocal('refs/heads/%s' % branch)))
|
||||||
|
cmd.extend(spec)
|
||||||
|
|
||||||
|
shallowfetch = self.config.GetString('repo.shallowfetch')
|
||||||
|
if shallowfetch and shallowfetch != ' '.join(spec):
|
||||||
|
GitCommand(self, ['fetch', '--unshallow', 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):
|
||||||
@ -2205,6 +2217,14 @@ class Project(object):
|
|||||||
if name in symlink_dirs and not os.path.lexists(src):
|
if name in symlink_dirs and not os.path.lexists(src):
|
||||||
os.makedirs(src)
|
os.makedirs(src)
|
||||||
|
|
||||||
|
# If the source file doesn't exist, ensure the destination
|
||||||
|
# file doesn't either.
|
||||||
|
if name in symlink_files and not os.path.lexists(src):
|
||||||
|
try:
|
||||||
|
os.remove(dst)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
if name in to_symlink:
|
if name in to_symlink:
|
||||||
os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
|
os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
|
||||||
elif copy_all and not os.path.islink(dst):
|
elif copy_all and not os.path.islink(dst):
|
||||||
|
Loading…
Reference in New Issue
Block a user