Skip to content

Commit b362a60

Browse files
committed
fetch: clobber existing tags with --prune-tags
This was documented but not implemented. In the flag description: prune local tags no longer on remote *and clobber changed tags* In the documentation: ... to prune local tags that don't exist on the remote, *and force-update those tags that differ*.
1 parent 8c6462e commit b362a60

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ static int update_local_ref(struct ref *ref,
981981
starts_with(ref->name, "refs/tags/")) {
982982
struct ref_update_display_info *info;
983983

984-
if (force || ref->force) {
984+
if (force || ref->force || prune_tags) {
985985
int r;
986986

987987
r = s_update_ref("updating tag", ref, transaction, 0);

t/t5516-fetch-push.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ test_force_fetch_tag () {
10921092
tag_type_description=$1
10931093
tag_args=$2
10941094

1095-
test_expect_success "fetch will not clobber an existing $tag_type_description without --force" "
1095+
test_expect_success "fetch will not clobber an existing $tag_type_description without --force or --prune-tags" "
10961096
mk_test testrepo heads/main &&
10971097
mk_child testrepo child1 &&
10981098
mk_child testrepo child2 &&
@@ -1108,7 +1108,13 @@ test_force_fetch_tag () {
11081108
git -C ../child1 fetch origin '+refs/tags/*:refs/tags/*' &&
11091109
git tag $tag_args testTag HEAD^ &&
11101110
test_must_fail git -C ../child1 fetch origin tag testTag &&
1111-
git -C ../child1 fetch --force origin tag testTag
1111+
git -C ../child1 fetch --force origin tag testTag &&
1112+
git tag $tag_args testTag HEAD &&
1113+
test_must_fail git -C ../child1 fetch origin tag testTag &&
1114+
git -C ../child1 fetch --prune-tags origin tag testTag &&
1115+
git tag $tag_args testTag HEAD^ &&
1116+
test_must_fail git -C ../child1 fetch origin tag testTag &&
1117+
git -C ../child1 -c fetch.prunetags=true fetch origin tag testTag
11121118
)
11131119
"
11141120
}

0 commit comments

Comments
 (0)