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>
This commit is contained in:
Xin Li 2019-09-16 10:55:41 -07:00
parent 70d861fa29
commit a2cd6aeae8

View File

@ -2186,12 +2186,15 @@ class Project(object):
cmd.append('--update-head-ok') cmd.append('--update-head-ok')
cmd.append(name) cmd.append(name)
spec = []
# If using depth then we should not get all the tags since they may # If using depth then we should not get all the tags since they may
# be outside of the depth. # be outside of the depth.
if no_tags or depth: if no_tags or depth:
cmd.append('--no-tags') cmd.append('--no-tags')
else: else:
cmd.append('--tags') cmd.append('--tags')
spec.append(str((u'+refs/tags/*:') + remote.ToLocal('refs/tags/*')))
if force_sync: if force_sync:
cmd.append('--force') cmd.append('--force')
@ -2202,12 +2205,9 @@ class Project(object):
if submodules: if submodules:
cmd.append('--recurse-submodules=on-demand') cmd.append('--recurse-submodules=on-demand')
spec = []
if not current_branch_only: if not current_branch_only:
# Fetch whole repo # Fetch whole repo
spec.append(str((u'+refs/heads/*:') + remote.ToLocal('refs/heads/*'))) 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: elif tag_name is not None:
spec.append('tag') spec.append('tag')
spec.append(tag_name) spec.append(tag_name)