Fix tag clobbering when -c is used.
Bug: b/140189154
Change-Id: I8861a6115b20c9a3d88ddec5344c75326ae44823
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/237572
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Xin Li <delphij@google.com>
diff --git a/project.py b/project.py
index 03a75f4..a20b413 100755
--- a/project.py
+++ b/project.py
@@ -2186,12 +2186,15 @@
cmd.append('--update-head-ok')
cmd.append(name)
+ spec = []
+
# If using depth then we should not get all the tags since they may
# be outside of the depth.
if no_tags or depth:
cmd.append('--no-tags')
else:
cmd.append('--tags')
+ spec.append(str((u'+refs/tags/*:') + remote.ToLocal('refs/tags/*')))
if force_sync:
cmd.append('--force')
@@ -2202,12 +2205,9 @@
if submodules:
cmd.append('--recurse-submodules=on-demand')
- spec = []
if not current_branch_only:
# Fetch whole repo
spec.append(str((u'+refs/heads/*:') + remote.ToLocal('refs/heads/*')))
- if not (no_tags or depth):
- spec.append(str((u'+refs/tags/*:') + remote.ToLocal('refs/tags/*')))
elif tag_name is not None:
spec.append('tag')
spec.append(tag_name)