From e57f1146de4324dc0f9c6c95fb9897b0e78dfd36 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 18 Mar 2019 21:27:54 -0400 Subject: [PATCH] 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 6e53844f1edd3 "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 --- project.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/project.py b/project.py index 274241e1..94aa816b 100755 --- a/project.py +++ b/project.py @@ -1306,7 +1306,7 @@ class Project(object): not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, current_branch_only=current_branch_only, no_tags=no_tags, prune=prune, depth=depth, - submodules=submodules)): + submodules=submodules, force_sync=force_sync)): return False mp = self.manifest.manifestProject @@ -1955,7 +1955,8 @@ class Project(object): no_tags=False, prune=False, depth=None, - submodules=False): + submodules=False, + force_sync=False): is_sha1 = False tag_name = None @@ -2068,6 +2069,9 @@ class Project(object): else: cmd.append('--tags') + if force_sync: + cmd.append('--force') + if prune: cmd.append('--prune')