sync: respect --force-sync when fetching updates

If a tag is rewritten on the server (which is bad), trying to recover
locally with `repo sync --force-sync` doesn't actually work.  People
have to manually delete things themselves to fix syncing.  While tags
should never be rewritten in practice, allow users to easily recover
from broken servers.

We updated some of these code paths already (see commit 6e53844f1e
"Allow clobbering of existing tags from remote."), but the incremental
update flow was missed.

Bug: b/120778183
Bug: chromium:932651
Test: delete local tag & recreate to diff commit, then check
      `repo sync` & `repo sync --force-sync` behavior
Change-Id: I3648f7d2526732c06016b691a9a36c003157618d
This commit is contained in:
Mike Frysinger 2019-03-18 21:27:54 -04:00
parent 01019d94af
commit e57f1146de

View File

@ -1306,7 +1306,7 @@ class Project(object):
not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
current_branch_only=current_branch_only, current_branch_only=current_branch_only,
no_tags=no_tags, prune=prune, depth=depth, no_tags=no_tags, prune=prune, depth=depth,
submodules=submodules)): submodules=submodules, force_sync=force_sync)):
return False return False
mp = self.manifest.manifestProject mp = self.manifest.manifestProject
@ -1955,7 +1955,8 @@ class Project(object):
no_tags=False, no_tags=False,
prune=False, prune=False,
depth=None, depth=None,
submodules=False): submodules=False,
force_sync=False):
is_sha1 = False is_sha1 = False
tag_name = None tag_name = None
@ -2068,6 +2069,9 @@ class Project(object):
else: else:
cmd.append('--tags') cmd.append('--tags')
if force_sync:
cmd.append('--force')
if prune: if prune:
cmd.append('--prune') cmd.append('--prune')