]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Import.pm
c7a96e1eabcc1214e6cdc61572ba6ed70db64750
[public-inbox.git] / lib / PublicInbox / Import.pm
1 # Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 #
4 # git fast-import-based ssoma-mda MDA replacement
5 # This is only ever run by public-inbox-mda and public-inbox-learn,
6 # not the WWW or NNTP code which only requires read-only access.
7 package PublicInbox::Import;
8 use strict;
9 use warnings;
10 use base qw(PublicInbox::Lock);
11 use PublicInbox::Spawn qw(spawn);
12 use PublicInbox::MID qw(mids mid_mime mid2path);
13 use PublicInbox::Address;
14 use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
15 use PublicInbox::ContentId qw(content_digest);
16 use PublicInbox::MDA;
17 use POSIX qw(strftime);
18
19 sub new {
20         my ($class, $git, $name, $email, $ibx) = @_;
21         my $ref = 'refs/heads/master';
22         if ($ibx) {
23                 $ref = $ibx->{ref_head} || 'refs/heads/master';
24                 $name ||= $ibx->{name};
25                 $email ||= $ibx->{-primary_address};
26         }
27         bless {
28                 git => $git,
29                 ident => "$name <$email>",
30                 mark => 1,
31                 ref => $ref,
32                 inbox => $ibx,
33                 path_type => '2/38', # or 'v2'
34                 lock_path => "$git->{git_dir}/ssoma.lock", # v2 changes this
35                 bytes_added => 0,
36         }, $class
37 }
38
39 # idempotent start function
40 sub gfi_start {
41         my ($self) = @_;
42
43         return ($self->{in}, $self->{out}) if $self->{pid};
44
45         my ($in_r, $in_w, $out_r, $out_w);
46         pipe($in_r, $in_w) or die "pipe failed: $!";
47         pipe($out_r, $out_w) or die "pipe failed: $!";
48         my $git = $self->{git};
49
50         $self->lock_acquire;
51
52         local $/ = "\n";
53         my $ref = $self->{ref};
54         chomp($self->{tip} = $git->qx(qw(rev-parse --revs-only), $ref));
55         if ($self->{path_type} ne '2/38' && $self->{tip}) {
56                 local $/ = "\0";
57                 my @tree = $git->qx(qw(ls-tree -r -z --name-only), $ref);
58                 chomp @tree;
59                 $self->{-tree} = { map { $_ => 1 } @tree };
60         }
61
62         my $git_dir = $git->{git_dir};
63         my @cmd = ('git', "--git-dir=$git_dir", qw(fast-import
64                         --quiet --done --date-format=raw));
65         my $rdr = { 0 => fileno($out_r), 1 => fileno($in_w) };
66         my $pid = spawn(\@cmd, undef, $rdr);
67         die "spawn fast-import failed: $!" unless defined $pid;
68         $out_w->autoflush(1);
69         $self->{in} = $in_r;
70         $self->{out} = $out_w;
71         $self->{pid} = $pid;
72         $self->{nchg} = 0;
73         binmode $out_w, ':raw' or die "binmode :raw failed: $!";
74         binmode $in_r, ':raw' or die "binmode :raw failed: $!";
75         ($in_r, $out_w);
76 }
77
78 sub wfail () { die "write to fast-import failed: $!" }
79
80 sub now_raw () { time . ' +0000' }
81
82 sub norm_body ($) {
83         my ($mime) = @_;
84         my $b = $mime->body_raw;
85         $b =~ s/(\r?\n)+\z//s;
86         $b
87 }
88
89 # only used for v1 (ssoma) inboxes
90 sub _check_path ($$$$) {
91         my ($r, $w, $tip, $path) = @_;
92         return if $tip eq '';
93         print $w "ls $tip $path\n" or wfail;
94         local $/ = "\n";
95         defined(my $info = <$r>) or die "EOF from fast-import: $!";
96         $info =~ /\Amissing / ? undef : $info;
97 }
98
99 sub _cat_blob ($$$) {
100         my ($r, $w, $oid) = @_;
101         print $w "cat-blob $oid\n" or wfail;
102         local $/ = "\n";
103         my $info = <$r>;
104         defined $info or die "EOF from fast-import / cat-blob: $!";
105         $info =~ /\A[a-f0-9]{40} blob (\d+)\n\z/ or return;
106         my $left = $1;
107         my $offset = 0;
108         my $buf = '';
109         my $n;
110         while ($left > 0) {
111                 $n = read($r, $buf, $left, $offset);
112                 defined($n) or die "read cat-blob failed: $!";
113                 $n == 0 and die 'fast-export (cat-blob) died';
114                 $left -= $n;
115                 $offset += $n;
116         }
117         $n = read($r, my $lf, 1);
118         defined($n) or die "read final byte of cat-blob failed: $!";
119         die "bad read on final byte: <$lf>" if $lf ne "\n";
120         \$buf;
121 }
122
123 sub cat_blob {
124         my ($self, $oid) = @_;
125         my ($r, $w) = $self->gfi_start;
126         _cat_blob($r, $w, $oid);
127 }
128
129 sub check_remove_v1 {
130         my ($r, $w, $tip, $path, $mime) = @_;
131
132         my $info = _check_path($r, $w, $tip, $path) or return ('MISSING',undef);
133         $info =~ m!\A100644 blob ([a-f0-9]{40})\t!s or die "not blob: $info";
134         my $oid = $1;
135         my $msg = _cat_blob($r, $w, $oid) or die "BUG: cat-blob $1 failed";
136         my $cur = PublicInbox::MIME->new($msg);
137         my $cur_s = $cur->header('Subject');
138         $cur_s = '' unless defined $cur_s;
139         my $cur_m = $mime->header('Subject');
140         $cur_m = '' unless defined $cur_m;
141         if ($cur_s ne $cur_m || norm_body($cur) ne norm_body($mime)) {
142                 return ('MISMATCH', $cur);
143         }
144         (undef, $cur);
145 }
146
147 sub checkpoint {
148         my ($self) = @_;
149         return unless $self->{pid};
150         print { $self->{out} } "checkpoint\n" or wfail;
151         undef;
152 }
153
154 sub progress {
155         my ($self, $msg) = @_;
156         return unless $self->{pid};
157         print { $self->{out} } "progress $msg\n" or wfail;
158         $self->{in}->getline eq "progress $msg\n" or die
159                 "progress $msg not received\n";
160         undef;
161 }
162
163 sub _update_git_info ($$) {
164         my ($self, $do_gc) = @_;
165         # for compatibility with existing ssoma installations
166         # we can probably remove this entirely by 2020
167         my $git_dir = $self->{git}->{git_dir};
168         my @cmd = ('git', "--git-dir=$git_dir");
169         my $index = "$git_dir/ssoma.index";
170         if (-e $index && !$ENV{FAST}) {
171                 my $env = { GIT_INDEX_FILE => $index };
172                 run_die([@cmd, qw(read-tree -m -v -i), $self->{ref}], $env);
173         }
174         run_die([@cmd, 'update-server-info'], undef);
175         ($self->{path_type} eq '2/38') and eval {
176                 require PublicInbox::SearchIdx;
177                 my $inbox = $self->{inbox} || $git_dir;
178                 my $s = PublicInbox::SearchIdx->new($inbox);
179                 $s->index_sync({ ref => $self->{ref} });
180         };
181         eval { run_die([@cmd, qw(gc --auto)], undef) } if $do_gc;
182 }
183
184 sub barrier {
185         my ($self) = @_;
186
187         # For safety, we ensure git checkpoint is complete before because
188         # the data in git is still more important than what is in Xapian
189         # in v2.  Performance may be gained by delaying the ->progress
190         # call but we lose safety
191         if ($self->{nchg}) {
192                 $self->checkpoint;
193                 $self->progress('checkpoint');
194                 _update_git_info($self, 0);
195                 $self->{nchg} = 0;
196         }
197 }
198
199 # used for v2
200 sub get_mark {
201         my ($self, $mark) = @_;
202         die "not active\n" unless $self->{pid};
203         my ($r, $w) = $self->gfi_start;
204         print $w "get-mark $mark\n" or wfail;
205         defined(my $oid = <$r>) or die "get-mark failed, need git 2.6.0+\n";
206         chomp($oid);
207         $oid;
208 }
209
210 # returns undef on non-existent
211 # ('MISMATCH', Email::MIME) on mismatch
212 # (:MARK, Email::MIME) on success
213 #
214 # v2 callers should check with Xapian before calling this as
215 # it is not idempotent.
216 sub remove {
217         my ($self, $mime, $msg) = @_; # mime = Email::MIME
218
219         my $path_type = $self->{path_type};
220         my ($path, $err, $cur, $blob);
221
222         my ($r, $w) = $self->gfi_start;
223         my $tip = $self->{tip};
224         if ($path_type eq '2/38') {
225                 $path = mid2path(v1_mid0($mime));
226                 ($err, $cur) = check_remove_v1($r, $w, $tip, $path, $mime);
227                 return ($err, $cur) if $err;
228         } else {
229                 my $sref;
230                 if (ref($mime) eq 'SCALAR') { # optimization used by V2Writable
231                         $sref = $mime;
232                 } else { # XXX should not be necessary:
233                         my $str = $mime->as_string;
234                         $sref = \$str;
235                 }
236                 my $len = length($$sref);
237                 $blob = $self->{mark}++;
238                 print $w "blob\nmark :$blob\ndata $len\n",
239                         $$sref, "\n" or wfail;
240         }
241
242         my $ref = $self->{ref};
243         my $commit = $self->{mark}++;
244         my $parent = $tip =~ /\A:/ ? $tip : undef;
245         unless ($parent) {
246                 print $w "reset $ref\n" or wfail;
247         }
248         my $ident = $self->{ident};
249         my $now = now_raw();
250         $msg ||= 'rm';
251         my $len = length($msg) + 1;
252         print $w "commit $ref\nmark :$commit\n",
253                 "author $ident $now\n",
254                 "committer $ident $now\n",
255                 "data $len\n$msg\n\n",
256                 'from ', ($parent ? $parent : $tip), "\n" or wfail;
257         if (defined $path) {
258                 print $w "D $path\n\n" or wfail;
259         } else {
260                 clean_tree_v2($self, $w, 'd');
261                 print $w "M 100644 :$blob d\n\n" or wfail;
262         }
263         $self->{nchg}++;
264         (($self->{tip} = ":$commit"), $cur);
265 }
266
267 sub git_timestamp {
268         my ($ts, $zone) = @_;
269         $ts = 0 if $ts < 0; # git uses unsigned times
270         "$ts $zone";
271 }
272
273 sub extract_author_info ($) {
274         my ($mime) = @_;
275
276         my $sender = '';
277         my $from = $mime->header('From');
278         my ($email) = PublicInbox::Address::emails($from);
279         my ($name) = PublicInbox::Address::names($from);
280         if (!defined($name) || !defined($email)) {
281                 $sender = $mime->header('Sender');
282                 if (!defined($name)) {
283                         ($name) = PublicInbox::Address::names($sender);
284                 }
285                 if (!defined($email)) {
286                         ($email) = PublicInbox::Address::emails($sender);
287                 }
288         }
289         if (defined $email) {
290                 # quiet down wide character warnings with utf8::encode
291                 utf8::encode($email);
292         } else {
293                 $email = '';
294                 warn "no email in From: $from or Sender: $sender\n";
295         }
296
297         # git gets confused with:
298         #  "'A U Thor <u@example.com>' via foo" <foo@example.com>
299         # ref:
300         # <CAD0k6qSUYANxbjjbE4jTW4EeVwOYgBD=bXkSu=akiYC_CB7Ffw@mail.gmail.com>
301         if (defined $name) {
302                 $name =~ tr/<>//d;
303                 utf8::encode($name);
304         } else {
305                 $name = '';
306                 warn "no name in From: $from or Sender: $sender\n";
307         }
308         ($name, $email);
309 }
310
311 # kill potentially confusing/misleading headers
312 sub drop_unwanted_headers ($) {
313         my ($mime) = @_;
314
315         $mime->header_set($_) for qw(bytes lines content-length status);
316         $mime->header_set($_) for @PublicInbox::MDA::BAD_HEADERS;
317 }
318
319 # used by V2Writable, too
320 sub append_mid ($$) {
321         my ($hdr, $mid0) = @_;
322         # @cur is likely empty if we need to call this sub, but it could
323         # have random unparseable crap which we'll preserve, too.
324         my @cur = $hdr->header_raw('Message-ID');
325         $hdr->header_set('Message-ID', @cur, "<$mid0>");
326 }
327
328 sub v1_mid0 ($) {
329         my ($mime) = @_;
330         my $hdr = $mime->header_obj;
331         my $mids = mids($hdr);
332
333         if (!scalar(@$mids)) { # spam often has no Message-Id
334                 my $mid0 = digest2mid(content_digest($mime), $hdr);
335                 append_mid($hdr, $mid0);
336                 return $mid0;
337         }
338         $mids->[0];
339 }
340 sub clean_tree_v2 ($$$) {
341         my ($self, $w, $keep) = @_;
342         my $tree = $self->{-tree} or return; #v2 only
343         delete $tree->{$keep};
344         foreach (keys %$tree) {
345                 print $w "D $_\n" or wfail;
346         }
347         %$tree = ($keep => 1);
348 }
349
350 # returns undef on duplicate
351 # returns the :MARK of the most recent commit
352 sub add {
353         my ($self, $mime, $check_cb) = @_; # mime = Email::MIME
354
355         my ($name, $email) = extract_author_info($mime);
356         my $hdr = $mime->header_obj;
357         my @at = msg_datestamp($hdr);
358         my @ct = msg_timestamp($hdr);
359         my $author_time_raw = git_timestamp(@at);
360         my $commit_time_raw = git_timestamp(@ct);
361         my $subject = $mime->header('Subject');
362         $subject = '(no subject)' unless defined $subject;
363         my $path_type = $self->{path_type};
364
365         my $path;
366         if ($path_type eq '2/38') {
367                 $path = mid2path(v1_mid0($mime));
368         } else { # v2 layout, one file:
369                 $path = 'm';
370         }
371
372         my ($r, $w) = $self->gfi_start;
373         my $tip = $self->{tip};
374         if ($path_type eq '2/38') {
375                 _check_path($r, $w, $tip, $path) and return;
376         }
377
378         drop_unwanted_headers($mime);
379
380         # spam check:
381         if ($check_cb) {
382                 $mime = $check_cb->($mime) or return;
383         }
384
385         my $blob = $self->{mark}++;
386         my $str = $mime->as_string;
387         my $n = length($str);
388         $self->{bytes_added} += $n;
389         print $w "blob\nmark :$blob\ndata ", $n, "\n" or wfail;
390         print $w $str, "\n" or wfail;
391
392         # v2: we need this for Xapian
393         if ($self->{want_object_info}) {
394                 my $oid = $self->get_mark(":$blob");
395                 $self->{last_object} = [ $oid, $n, \$str ];
396         }
397         my $ref = $self->{ref};
398         my $commit = $self->{mark}++;
399         my $parent = $tip =~ /\A:/ ? $tip : undef;
400
401         unless ($parent) {
402                 print $w "reset $ref\n" or wfail;
403         }
404
405         utf8::encode($subject);
406         print $w "commit $ref\nmark :$commit\n",
407                 "author $name <$email> $author_time_raw\n",
408                 "committer $self->{ident} $commit_time_raw\n" or wfail;
409         print $w "data ", (length($subject) + 1), "\n",
410                 $subject, "\n\n" or wfail;
411         if ($tip ne '') {
412                 print $w 'from ', ($parent ? $parent : $tip), "\n" or wfail;
413         }
414         clean_tree_v2($self, $w, $path);
415         print $w "M 100644 :$blob $path\n\n" or wfail;
416         $self->{nchg}++;
417         $self->{tip} = ":$commit";
418 }
419
420 sub run_die ($;$$) {
421         my ($cmd, $env, $rdr) = @_;
422         my $pid = spawn($cmd, $env, $rdr);
423         defined $pid or die "spawning ".join(' ', @$cmd)." failed: $!";
424         waitpid($pid, 0) == $pid or die join(' ', @$cmd) .' did not finish';
425         $? == 0 or die join(' ', @$cmd) . " failed: $?\n";
426 }
427
428 sub done {
429         my ($self) = @_;
430         my $w = delete $self->{out} or return;
431         my $r = delete $self->{in} or die 'BUG: missing {in} when done';
432         print $w "done\n" or wfail;
433         my $pid = delete $self->{pid} or die 'BUG: missing {pid} when done';
434         waitpid($pid, 0) == $pid or die 'fast-import did not finish';
435         $? == 0 or die "fast-import failed: $?";
436
437         _update_git_info($self, 1) if delete $self->{nchg};
438
439         $self->lock_release;
440 }
441
442 sub atfork_child {
443         my ($self) = @_;
444         foreach my $f (qw(in out)) {
445                 close $self->{$f} or die "failed to close import[$f]: $!\n";
446         }
447 }
448
449 sub digest2mid ($$) {
450         my ($dig, $hdr) = @_;
451         my $b64 = $dig->clone->b64digest;
452         # Make our own URLs nicer:
453         # See "Base 64 Encoding with URL and Filename Safe Alphabet" in RFC4648
454         $b64 =~ tr!+/=!-_!d;
455
456         # Add a date prefix to prevent a leading '-' in case that trips
457         # up some tools (e.g. if a Message-ID were a expected as a
458         # command-line arg)
459         my $dt = msg_datestamp($hdr);
460         $dt = POSIX::strftime('%Y%m%d%H%M%S', gmtime($dt));
461         "$dt.$b64" . '@z';
462 }
463
464 sub clean_purge_buffer {
465         my ($oids, $buf) = @_;
466         my $cmt_msg = 'purged '.join(' ',@$oids)."\n";
467         @$oids = ();
468
469         foreach my $i (0..$#$buf) {
470                 my $l = $buf->[$i];
471                 if ($l =~ /^author .* (\d+ [\+-]?\d+)$/) {
472                         $buf->[$i] = "author <> $1\n";
473                 } elsif ($l =~ /^data (\d+)/) {
474                         $buf->[$i++] = "data " . length($cmt_msg) . "\n";
475                         $buf->[$i] = $cmt_msg;
476                         last;
477                 }
478         }
479 }
480
481 sub purge_oids {
482         my ($self, $purge) = @_;
483         my $tmp = "refs/heads/purge-".((keys %$purge)[0]);
484         my $old = $self->{'ref'};
485         my $git = $self->{git};
486         my @export = (qw(fast-export --no-data --use-done-feature), $old);
487         my ($rd, $pid) = $git->popen(@export);
488         my ($r, $w) = $self->gfi_start;
489         my @buf;
490         my $npurge = 0;
491         my @oids;
492         my ($done, $mark);
493         my $tree = $self->{-tree};
494         while (<$rd>) {
495                 if (/^reset (?:.+)/) {
496                         push @buf, "reset $tmp\n";
497                 } elsif (/^commit (?:.+)/) {
498                         if (@buf) {
499                                 $w->print(@buf) or wfail;
500                                 @buf = ();
501                         }
502                         push @buf, "commit $tmp\n";
503                 } elsif (/^data (\d+)/) {
504                         # only commit message, so $len is small:
505                         my $len = $1; # + 1 for trailing "\n"
506                         push @buf, $_;
507                         my $n = read($rd, my $buf, $len) or die "read: $!";
508                         $len == $n or die "short read ($n < $len)";
509                         push @buf, $buf;
510                 } elsif (/^M 100644 ([a-f0-9]+) (\w+)/) {
511                         my ($oid, $path) = ($1, $2);
512                         if ($purge->{$oid}) {
513                                 push @oids, $oid;
514                                 delete $tree->{$path};
515                         } else {
516                                 $tree->{$path} = 1;
517                                 push @buf, $_;
518                         }
519                 } elsif (/^D (\w+)/) {
520                         my $path = $1;
521                         push @buf, $_ if $tree->{$path};
522                 } elsif ($_ eq "\n") {
523                         if (@oids) {
524                                 my $out = join('', @buf);
525                                 $out =~ s/^/# /sgm;
526                                 warn "purge rewriting\n", $out, "\n";
527                                 clean_purge_buffer(\@oids, \@buf);
528                                 $npurge++;
529                         }
530                         $w->print(@buf, "\n") or wfail;
531                         @buf = ();
532                 } elsif ($_ eq "done\n") {
533                         $done = 1;
534                 } elsif (/^mark :(\d+)$/) {
535                         push @buf, $_;
536                         $mark = $1;
537                 } else {
538                         push @buf, $_;
539                 }
540         }
541         if (@buf) {
542                 $w->print(@buf) or wfail;
543         }
544         die 'done\n not seen from fast-export' unless $done;
545         chomp(my $cmt = $self->get_mark(":$mark")) if $npurge;
546         $self->{nchg} = 0; # prevent _update_git_info until update-ref:
547         $self->done;
548         my @git = ('git', "--git-dir=$git->{git_dir}");
549
550         run_die([@git, qw(update-ref), $old, $tmp]) if $npurge;
551
552         run_die([@git, qw(update-ref -d), $tmp]);
553
554         return if $npurge == 0;
555
556         run_die([@git, qw(-c gc.reflogExpire=now gc --prune=all)]);
557         my $err = 0;
558         foreach my $oid (keys %$purge) {
559                 my @info = $git->check($oid);
560                 if (@info) {
561                         warn "$oid not purged\n";
562                         $err++;
563                 }
564         }
565         _update_git_info($self, 0);
566         die "Failed to purge $err object(s)\n" if $err;
567         $cmt;
568 }
569
570 1;
571 __END__
572 =pod
573
574 =head1 NAME
575
576 PublicInbox::Import - message importer for public-inbox
577
578 =head1 VERSION
579
580 version 1.0
581
582 =head1 SYNOPSYS
583
584         use Email::MIME;
585         use PublicInbox::Git;
586         use PublicInbox::Import;
587
588         chomp(my $git_dir = `git rev-parse --git-dir`);
589         $git_dir or die "GIT_DIR= must be specified\n";
590         my $git = PublicInbox::Git->new($git_dir);
591         my @committer = ('inbox', 'inbox@example.org');
592         my $im = PublicInbox::Import->new($git, @committer);
593
594         # to add a message:
595         my $message = "From: <u\@example.org>\n".
596                 "Subject: test message \n" .
597                 "Date: Thu, 01 Jan 1970 00:00:00 +0000\n" .
598                 "Message-ID: <m\@example.org>\n".
599                 "\ntest message";
600         my $parsed = Email::MIME->new($message);
601         my $ret = $im->add($parsed);
602         if (!defined $ret) {
603                 warn "duplicate: ",
604                         $parsed->header_obj->header_raw('Message-ID'), "\n";
605         } else {
606                 print "imported at mark $ret\n";
607         }
608         $im->done;
609
610         # to remove a message
611         my $junk = Email::MIME->new($message);
612         my ($mark, $orig) = $im->remove($junk);
613         if ($mark eq 'MISSING') {
614                 print "not found\n";
615         } elsif ($mark eq 'MISMATCH') {
616                 print "Message exists but does not match\n\n",
617                         $orig->as_string, "\n",;
618         } else {
619                 print "removed at mark $mark\n\n",
620                         $orig->as_string, "\n";
621         }
622         $im->done;
623
624 =head1 DESCRIPTION
625
626 An importer and remover for public-inboxes which takes L<Email::MIME>
627 messages as input and stores them in a ssoma repository as
628 documented in L<https://ssoma.public-inbox.org/ssoma_repository.txt>,
629 except it does not allow duplicate Message-IDs.
630
631 It requires L<git(1)> and L<git-fast-import(1)> to be installed.
632
633 =head1 METHODS
634
635 =cut
636
637 =head2 new
638
639         my $im = PublicInbox::Import->new($git, @committer);
640
641 Initialize a new PublicInbox::Import object.
642
643 =head2 add
644
645         my $parsed = Email::MIME->new($message);
646         $im->add($parsed);
647
648 Adds a message to to the git repository.  This will acquire
649 C<$GIT_DIR/ssoma.lock> and start L<git-fast-import(1)> if necessary.
650
651 Messages added will not be visible to other processes until L</done>
652 is called, but L</remove> may be called on them.
653
654 =head2 remove
655
656         my $junk = Email::MIME->new($message);
657         my ($code, $orig) = $im->remove($junk);
658
659 Removes a message from the repository.  On success, it returns
660 a ':'-prefixed numeric code representing the git-fast-import
661 mark and the original messages as an Email::MIME object.
662 If the message could not be found, the code is "MISSING"
663 and the original message is undef.  If there is a mismatch where
664 the "Message-ID" is matched but the subject and body do not match,
665 the returned code is "MISMATCH" and the conflicting message
666 is returned as orig.
667
668 =head2 done
669
670 Finalizes the L<git-fast-import(1)> and unlocks the repository.
671 Calling this is required to finalize changes to a repository.
672
673 =head1 SEE ALSO
674
675 L<Email::MIME>
676
677 =head1 CONTACT
678
679 All feedback welcome via plain-text mail to L<mailto:meta@public-inbox.org>
680
681 The mail archives are hosted at L<https://public-inbox.org/meta/>
682
683 =head1 COPYRIGHT
684
685 Copyright (C) 2016 all contributors L<mailto:meta@public-inbox.org>
686
687 License: AGPL-3.0+ L<http://www.gnu.org/licenses/agpl-3.0.txt>
688
689 =cut