From: "Orgad Shaneh via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Orgad Shaneh <orgads@gmail.com>,
Orgad Shaneh <orgad.shaneh@audiocodes.com>
Subject: [PATCH 2/2] fetch: clobber existing tags with --prune-tags
Date: Sun, 15 Feb 2026 20:23:36 +0000 [thread overview]
Message-ID: <b444fa7af9f39960652209143c9845a47efd58e1.1771187016.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2200.git.git.1771187016.gitgitgadget@gmail.com>
From: Orgad Shaneh <orgad.shaneh@audiocodes.com>
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*.
Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
---
builtin/fetch.c | 2 +-
t/t5516-fetch-push.sh | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index a3bc7e9380..c212f50b86 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -981,7 +981,7 @@ static int update_local_ref(struct ref *ref,
starts_with(ref->name, "refs/tags/")) {
struct ref_update_display_info *info;
- if (force || ref->force) {
+ if (force || ref->force || prune_tags) {
int r;
r = s_update_ref("updating tag", ref, transaction, 0);
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
)
"
}
--
gitgitgadget
next prev parent reply other threads:[~2026-02-15 20:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-15 20:23 [PATCH 0/2] fetch: clobber existing tags with --prune-tags Orgad Shaneh via GitGitGadget
2026-02-15 20:23 ` [PATCH 1/2] fetch: add a test for --force flag Orgad Shaneh via GitGitGadget
2026-02-15 20:23 ` Orgad Shaneh via GitGitGadget [this message]
2026-03-18 8:27 ` [PATCH 2/2] fetch: clobber existing tags with --prune-tags Orgad Shaneh
2026-03-21 18:26 ` Junio C Hamano
2026-03-26 7:57 ` Orgad Shaneh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b444fa7af9f39960652209143c9845a47efd58e1.1771187016.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=orgad.shaneh@audiocodes.com \
--cc=orgads@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox