summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-03-18 21:27:54 -0400
committerMike Frysinger <vapier@google.com>2019-03-18 21:31:03 -0400
commite57f1146de4324dc0f9c6c95fb9897b0e78dfd36 (patch)
treea42910d442974086a379a302df024adffd61dee4
parent01019d94af1b7ae046d69af632ce2cb4afb4a6fe (diff)
downloadgit-repo-e57f1146de4324dc0f9c6c95fb9897b0e78dfd36.tar.gz
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
-rwxr-xr-xproject.py8
1 files 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):
1306 not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, 1306 not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
1307 current_branch_only=current_branch_only, 1307 current_branch_only=current_branch_only,
1308 no_tags=no_tags, prune=prune, depth=depth, 1308 no_tags=no_tags, prune=prune, depth=depth,
1309 submodules=submodules)): 1309 submodules=submodules, force_sync=force_sync)):
1310 return False 1310 return False
1311 1311
1312 mp = self.manifest.manifestProject 1312 mp = self.manifest.manifestProject
@@ -1955,7 +1955,8 @@ class Project(object):
1955 no_tags=False, 1955 no_tags=False,
1956 prune=False, 1956 prune=False,
1957 depth=None, 1957 depth=None,
1958 submodules=False): 1958 submodules=False,
1959 force_sync=False):
1959 1960
1960 is_sha1 = False 1961 is_sha1 = False
1961 tag_name = None 1962 tag_name = None
@@ -2068,6 +2069,9 @@ class Project(object):
2068 else: 2069 else:
2069 cmd.append('--tags') 2070 cmd.append('--tags')
2070 2071
2072 if force_sync:
2073 cmd.append('--force')
2074
2071 if prune: 2075 if prune:
2072 cmd.append('--prune') 2076 cmd.append('--prune')
2073 2077