Code

filter-branch: be more helpful when an annotated tag changes
authorThomas Rast <trast@student.ethz.ch>
Thu, 7 Aug 2008 23:50:31 +0000 (01:50 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Aug 2008 23:19:51 +0000 (16:19 -0700)
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>
git-filter-branch.sh

index 182822a24e214fe7e93a2df68fdda3dd40b5896d..a324cf0596ee0f05831190ce724fe9134bc7f568 100755 (executable)
@@ -361,9 +361,17 @@ do
        ;;
        $_x40)
                echo "Ref '$ref' was rewritten"
-               git update-ref -m "filter-branch: rewrite" \
-                               "$ref" $rewritten $sha1 ||
-                       die "Could not rewrite $ref"
+               if ! git update-ref -m "filter-branch: rewrite" \
+                                       "$ref" $rewritten $sha1 2>/dev/null; then
+                       if test $(git cat-file -t "$ref") = tag; then
+                               if test -z "$filter_tag_name"; then
+                                       warn "WARNING: You said to rewrite tagged commits, but not the corresponding tag."
+                                       warn "WARNING: Perhaps use '--tag-name-filter cat' to rewrite the tag."
+                               fi
+                       else
+                               die "Could not rewrite $ref"
+                       fi
+               fi
        ;;
        *)
                # NEEDSWORK: possibly add -Werror, making this an error