@matheusbsbs / matheus-bagliano / commits / 261044e85d
Fork 0

filter-branch: be more helpful when an annotated tag changes

Previously, git-filter-branch failed if it attempted to update an annotated tag. Now we ignore this condition if --tag-name-filter is given, so that we can later rewrite the tag. If no such option was provided, we warn the user that he might want to run with "--tag-name-filter cat" to achieve the intended effect. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Aug 8, 2008 at 01:50 UTC 261044e85ddac3de48dc74dd9c416c95147022ad
1 file changed +11 -3
git-filter-branch.sh
+11 -3
@@ -361,9 +361,17 @@ do
361 ;;
362 $_x40)
363 echo "Ref '$ref' was rewritten"
364 - git update-ref -m "filter-branch: rewrite" \
365 - "$ref" $rewritten $sha1 ||
366 - die "Could not rewrite $ref"
364 + if ! git update-ref -m "filter-branch: rewrite" \
365 + "$ref" $rewritten $sha1 2>/dev/null; then
366 + if test $(git cat-file -t "$ref") = tag; then
367 + if test -z "$filter_tag_name"; then
368 + warn "WARNING: You said to rewrite tagged commits, but not the corresponding tag."
369 + warn "WARNING: Perhaps use '--tag-name-filter cat' to rewrite the tag."
370 + fi
371 + else
372 + die "Could not rewrite $ref"
373 + fi
374 + fi
375 ;;
376 *)
377 # NEEDSWORK: possibly add -Werror, making this an error