Git development
 help / color / mirror / Atom feed
From: Orgad Shaneh <orgads@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Karthik Nayak" <karthik.188@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 0/2] fetch: make --prune-tags clobber changed tags
Date: Sat, 21 Nov 2026 21:46:31 +0000	[thread overview]
Message-ID: <20261121214633.1523706-1-orgads@gmail.com> (raw)
In-Reply-To: <pull.2200.git.git.1771187016.gitgitgadget@gmail.com>

--prune-tags is documented to force-update tags that changed on the
remote, but since 0bc8d71b99 (Git 2.20) it rejects them with "would
clobber existing tag".

Changes since v1:

* Instead of treating --prune-tags like --force for tags, add "+" to
  the refspec that --prune-tags implies. v1 also forced tags fetched
  with an explicit refspec when fetch.pruneTags was set, even though
  tags are not pruned in that case.

* The commit message now says what fetch does today, and where this
  broke.

* The tests check that the local tag was actually updated, not only
  that fetch succeeded, and that "git fetch origin tag <name>" is still
  refused with fetch.pruneTags set.

* Rebased on current master.

Orgad Shaneh (2):
  fetch: test that --force clobbers a changed tag
  fetch: make --prune-tags clobber changed tags

 Documentation/config/fetch.adoc |  2 +-
 Documentation/git-fetch.adoc    |  2 +-
 builtin/fetch.c                 |  4 ++--
 t/t5516-fetch-push.sh           | 35 ++++++++++++++++++++++++++++++++-
 4 files changed, 38 insertions(+), 5 deletions(-)

Range-diff against v1:
1:  3a5b1c73a6 ! 1:  6ee374acd4 fetch: add a test for --force flag
    @@ Metadata
     Author: Orgad Shaneh <orgads@gmail.com>
     
      ## Commit message ##
    -    fetch: add a test for --force flag
    +    fetch: test that --force clobbers a changed tag
     
    -    There are two ways to force-fetch tags that have changed: either by
    -    specifying an explicit forced ref (+refs/tags/*:refs/tags/*), or by
    -    using --force.
    +    Changed tags can be force-fetched with a "+" refspec or with --force,
    +    but only the refspec was tested. The test also didn't check that the
    +    tag was actually updated, only that fetch succeeded.
     
    -    The first approach was already tested, but the second was not. This
    -    has now been addressed.
    +    Add the --force case, and check the tag after each forced fetch.
     
    -    Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
    +    Signed-off-by: Orgad Shaneh <orgads@gmail.com>
     
      ## t/t5516-fetch-push.sh ##
    +@@ t/t5516-fetch-push.sh: test_force_push_tag () {
    + test_force_push_tag "lightweight tag" "-f"
    + test_force_push_tag "annotated tag" "-f -a -m'tag message'"
    + 
    ++check_child1_tag () {
    ++	git rev-parse testTag >expect &&
    ++	git -C ../child1 rev-parse testTag >actual &&
    ++	test_cmp expect actual
    ++}
    ++
    + test_force_fetch_tag () {
    + 	tag_type_description=$1
    + 	tag_args=$2
     @@ t/t5516-fetch-push.sh: test_force_fetch_tag () {
      			git commit -m 'file1' &&
      			git tag $tag_args testTag &&
      			test_must_fail git -C ../child1 fetch origin tag testTag &&
     -			git -C ../child1 fetch origin '+refs/tags/*:refs/tags/*'
     +			git -C ../child1 fetch origin '+refs/tags/*:refs/tags/*' &&
    ++			check_child1_tag &&
     +			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 &&
    ++			check_child1_tag
      		)
      	"
      }
2:  ae82d31bfb < -:  ---------- fetch: clobber existing tags with --prune-tags
-:  ---------- > 2:  3ed44788d7 fetch: make --prune-tags clobber changed tags

base-commit: f7de81456940dd6f3274e461149bba12965de609
-- 
2.53.0


  parent reply	other threads:[~2026-11-21 21:46 UTC|newest]

Thread overview: 12+ 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 ` [PATCH 2/2] fetch: clobber existing tags with --prune-tags Orgad Shaneh via GitGitGadget
2026-03-18  8:27   ` Orgad Shaneh
2026-03-21 18:26   ` Junio C Hamano
2026-03-26  7:57     ` Orgad Shaneh
2026-09-13 19:03       ` Orgad Shaneh
2026-09-13 22:57         ` Junio C Hamano
2026-10-06 17:44           ` Orgad Shaneh
2026-11-21 21:46 ` Orgad Shaneh [this message]
2026-11-21 21:46   ` [PATCH v2 1/2] fetch: test that --force clobbers a changed tag Orgad Shaneh
2026-11-21 21:46   ` [PATCH v2 2/2] fetch: make --prune-tags clobber changed tags 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=20261121214633.1523706-1-orgads@gmail.com \
    --to=orgads@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=karthik.188@gmail.com \
    --cc=peff@peff.net \
    /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