]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-edit
Merge remote-tracking branch 'origin/edit' into next
[public-inbox.git] / script / public-inbox-edit
index ff0351a389cca4243a28a64971ba3b8533438da4..2e2c761620e154da65a395f6d9c6a12a756cb14f 100755 (executable)
@@ -14,6 +14,7 @@ use PublicInbox::MID qw(mid_clean mids);
 PublicInbox::Admin::check_require('-index');
 require PublicInbox::MIME;
 require PublicInbox::InboxWritable;
+require PublicInbox::Import;
 
 my $usage = "$0 -m MESSAGE_ID [--all] [INBOX_DIRS]";
 my $opt = { verbose => 1, all => 0, -min_inbox_version => 2, raw => 0 };
@@ -120,7 +121,7 @@ $mids
 
 my $tmpl = 'public-inbox-edit-XXXXXX';
 foreach my $to_edit (values %$found) {
-       my ($edit_fh, $edit_fn) = tempfile($tmpl, TMPDIR => 1);
+       my ($edit_fh, $edit_fn) = tempfile($tmpl, TMPDIR => 1, UNLINK => 1);
        $edit_fh->autoflush(1);
        my ($ibx, $smsg) = @{$to_edit->[0]};
        my $old_raw = $ibx->msg_by_smsg($smsg);
@@ -197,6 +198,11 @@ W: possible message boundary splitting error
        my $new_mime = PublicInbox::MIME->new(\$new_raw);
        my $old_mime = PublicInbox::MIME->new($old_raw);
 
+       # make sure we don't compare unwanted headers, since mutt adds
+       # Content-Length, Status, and Lines headers:
+       PublicInbox::Import::drop_unwanted_headers($new_mime);
+       PublicInbox::Import::drop_unwanted_headers($old_mime);
+
        # allow changing Received: and maybe other headers which can
        # contain sensitive info.
        my $nhdr = $new_mime->header_obj;
@@ -207,7 +213,7 @@ W: possible message boundary splitting error
 
                next unless $opt->{verbose};
                # should we consider this machine-parseable?
-               print "$ibx->{mainrepo}:\n\tNONE\n";
+               PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, []);
                next;
        }
 
@@ -223,11 +229,6 @@ W: possible message boundary splitting error
                }
                next unless $opt->{verbose};
                # should we consider this machine-parseable?
-               print "$ibx->{mainrepo}:";
-               if (scalar @$commits) {
-                       print join("\n\t", '', @$commits), "\n";
-               } else {
-                       print "\tNONE\n";
-               }
+               PublicInbox::AdminEdit::show_rewrites(\*STDOUT, $ibx, $commits);
        }
 }