Subject: Re: [PATCH 2/2] fetch: clobber existing tags with --prune-tags

From: Junio C Hamano <[email-masked]>
Date: Sat, 21 Mar 2026 11:26:59 -0700

"Orgad Shaneh via GitGitGadget" <[email-masked]> writes:

> From: Orgad Shaneh <[email-masked]>
>
> This was documented but not implemented.

And instead what did the command do / how did the command behave?

It also is curious when it was "broken".  It could be that it was
broken from day one when 97716d21 (fetch: add a --prune-tags option
and fetch.pruneTags config, 2018-02-09) was written, c1a7902f (Merge
branch 'ab/fetch-prune', 2018-03-06) merged it, and Git 2.17 was
shipped with it, but knowing Ævar (by the way where is he these
days???), I somehow doubt it.

And unless it was broken from day one, we must find out if the
change in behaviour was deliberate, in which case it would be the
doucmentation and not the implementation that needs fixing.

> 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*.
> ...
> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
> index 31df7faf56..4d29043baf 100755
> --- a/t/t5516-fetch-push.sh
> +++ b/t/t5516-fetch-push.sh
> @@ -1092,7 +1092,7 @@ test_force_fetch_tag () {
>  	tag_type_description=$1
>  	tag_args=$2
>  
> -	test_expect_success "fetch will not clobber an existing $tag_type_description without --force" "
> +	test_expect_success "fetch will not clobber an existing $tag_type_description without --force or --prune-tags" "
>  		mk_test testrepo heads/main &&
>  		mk_child testrepo child1 &&
>  		mk_child testrepo child2 &&
> @@ -1108,7 +1108,13 @@ test_force_fetch_tag () {
>  			git -C ../child1 fetch origin '+refs/tags/*:refs/tags/*' &&
>  			git tag $tag_args testTag HEAD^ &&
>  			test_must_fail git -C ../child1 fetch origin tag testTag &&
> -			git -C ../child1 fetch --force origin tag testTag
> +			git -C ../child1 fetch --force origin tag testTag &&
> +			git tag $tag_args testTag HEAD &&
> +			test_must_fail git -C ../child1 fetch origin tag testTag &&
> +			git -C ../child1 fetch --prune-tags origin tag testTag &&
> +			git tag $tag_args testTag HEAD^ &&
> +			test_must_fail git -C ../child1 fetch origin tag testTag &&
> +			git -C ../child1 -c fetch.prunetags=true fetch origin tag testTag
>  		)
>  	"
>  }

None of the steps we see in the added test do not seem to check that
--prune-tags does clobber existing tag that no longer exists on the
other side.  It only checks the "git fetch" command exits with
status 0, but does not see if the tag actually went away after the
operation is done.