+sub filter_updates () {
+ @updates = grep { $_->[1] ne $_->[2] } @updates;
+}
+
+sub rewrite_tag ($) {
+ my ($obj) = @_;
+ $_ = getobj $obj, 'tag';
+ m/^type (\w+)\n/m or die "$obj ?";
+ if ($1 ne 'commit') {
+ $count{"oddtags $1"}++;
+ return $obj;
+ }
+ m/^object (\w+)\n/m or die "$obj ?";
+ my $oldref = $1;
+ my $newref = rewrite_commit $oldref;
+ if ($oldref eq $newref) {
+ return $obj;
+ }
+ s/^(object )\w+$/ $1.$newref /me or die "$obj ($_) ?";
+ s/^-----BEGIN PGP SIGNATURE-----\n.*^-----END PGP SIGNATURE-----\n$//sm;
+ return hashobj $_, 'tag';
+}
+
+sub edit_rewrite_map ($) {
+ my ($old) = @_;
+
+ filter_updates();
+ return $old unless @updates;