]> Sergey Matveev's repositories - public-inbox.git/commitdiff
PublicInbox::Import::add: Consolidate subject handling
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 17 May 2019 01:53:06 +0000 (20:53 -0500)
committerEric Wong <e@80x24.org>
Fri, 17 May 2019 21:17:26 +0000 (21:17 +0000)
Consolidate subject handling in the add function to make it easier to
read and understand.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
lib/PublicInbox/Import.pm

index 12abf39995ffbcd1677f94be807828449e06c96c..81a38fb6987d4d403bc1be376d610b8305d69fe7 100644 (file)
@@ -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;