about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2019-05-16 20:53:06 -0500
committerEric Wong <e@80x24.org>2019-05-17 21:17:26 +0000
commit8c925f2e250853b62fdb2a4ebdd45c2bba71544e (patch)
tree874a8012e287ba9d7ce552efded6cbb97a5f5311
parent1ea73ea22b4d2ea3a9c123753bdc58f9d480e188 (diff)
downloadpublic-inbox-8c925f2e250853b62fdb2a4ebdd45c2bba71544e.tar.gz
Consolidate subject handling in the add function to make it easier to
read and understand.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-rw-r--r--lib/PublicInbox/Import.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 12abf399..81a38fb6 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -367,10 +367,14 @@ sub add {
         my @ct = msg_timestamp($hdr);
         my $author_time_raw = git_timestamp(@at);
         my $commit_time_raw = git_timestamp(@ct);
+
         my $subject = $mime->header('Subject');
         $subject = '(no subject)' unless defined $subject;
-        my $path_type = $self->{path_type};
+        # Mime decoding can create nulls replace them with spaces to protect git
+        $subject =~ tr/\0/ /;
+        utf8::encode($subject);
 
+        my $path_type = $self->{path_type};
         my $path;
         if ($path_type eq '2/38') {
                 $path = mid2path(v1_mid0($mime));
@@ -411,9 +415,6 @@ sub add {
                 print $w "reset $ref\n" or wfail;
         }
 
-        # Mime decoding can create nulls replace them with spaces to protect git
-        $subject =~ tr/\0/ /;
-        utf8::encode($subject);
         print $w "commit $ref\nmark :$commit\n",
                 "author $name <$email> $author_time_raw\n",
                 "committer $self->{ident} $commit_time_raw\n" or wfail;