use PublicInbox::LEI;
use PublicInbox::SolverGit;
+my $MODE = '(100644|120000|100755|160000)';
+
sub rediff_user_cb { # called by solver when done
my ($res, $self) = @_;
my $lei = $self->{lei};
my $tb = $ta;
$tb =~ tr!A!B!;
my $lei = $self->{lei};
- my $wait = delete($self->{-do_done}) ? $lei->{sto}->ipc_do('done') : 0;
- while (my ($oid_a, $oid_b, $pa, $pb) = splice(@$ctxq, 0, 4)) {
+ while (my ($oid_a, $oid_b, $pa, $pb, $ma, $mb) = splice(@$ctxq, 0, 6)) {
my $xa = $blob->{$oid_a} //= solve_1($self, $oid_a,
{ path_b => $pa });
my $xb = $blob->{$oid_b} //= solve_1($self, $oid_b, {
path_a => $pa,
path_b => $pb
});
- $ta .= "M 100644 $xa ".git_quote($pa)."\n" if $xa;
- $tb .= "M 100644 $xb ".git_quote($pb)."\n" if $xb;
+ $ta .= "M $ma $xa ".git_quote($pa)."\n" if $xa;
+ $tb .= "M $mb $xb ".git_quote($pb)."\n" if $xb;
}
my $rw = $self->{gits}->[-1]; # has all known alternates
if (!$rw->{-tmp}) {
push @cmd, '--'.($opt->{color} && !$opt->{'no-color'} ? '' : 'no-').
'color';
for my $o (@PublicInbox::LEI::diff_opt) {
- $o =~ s/\|([a-z0-9])\b//i; # remove single char short option
- my $c = $1;
+ my $c = '';
+ # remove single char short option
+ $o =~ s/\|([a-z0-9])\b//i and $c = $1;
if ($o =~ s/=[is]@\z//) {
my $v = $opt->{$o} or next;
push @cmd, map { $c ? "-$c$_" : "--$o=$_" } @$v;
if (scalar(@top) >= 4 &&
$top[1] =~ $PublicInbox::ViewDiff::IS_OID &&
$top[0] =~ $PublicInbox::ViewDiff::IS_OID) {
+ my ($ma, $mb);
+ $x =~ /^old mode $MODE/sm and $ma = $1;
+ $x =~ /^new mode $MODE/sm and $mb = $1;
+ if (!defined($ma) && $x =~
+ /^index [a-z0-9]+\.\.[a-z0-9]+ $MODE/sm) {
+ $ma = $mb = $1;
+ }
+ $ma //= '100644';
+ $mb //= $ma;
my ($oid_a, $oid_b, $pa, $pb) = splice(@top, 0, 4);
$pa eq '/dev/null' or
$pa = (split(m'/', git_unquote($pa), 2))[1];
$pb = (split(m'/', git_unquote($pb), 2))[1];
$blobs->{$oid_a} //= undef;
$blobs->{$oid_b} //= undef;
- push @$ctxq, $oid_a, $oid_b, $pa, $pb;
+ push @$ctxq, $oid_a, $oid_b, $pa, $pb, $ma, $mb;
} elsif ($ctxq) {
my @out;
for (split(/^/sm, $x)) {
sub input_eml_cb { # callback for all emails
my ($self, $eml) = @_;
- $self->{lei}->{sto}->ipc_do('add_eml', $eml);
- $self->{-do_done} = 1;
+ $self->{tmp_sto}->add_eml($eml);
+ $self->{tmp_sto}->done;
$eml->each_part(\&extract_oids, $self, 1);
}
sub lei_rediff {
my ($lei, @inputs) = @_;
$lei->_lei_store(1)->write_prepare($lei);
- $lei->{opt}->{stdin} = 1 if !@inputs;
$lei->{opt}->{'in-format'} //= 'eml';
# maybe it's a non-email (code) blob from a coderepo
my $git_dirs = $lei->{opt}->{'git-dir'} //= [];
$lei->{curl} //= which('curl') or return
$lei->fail('curl needed for', $lxs->remotes);
}
- $lei->ale->refresh_externals($lxs);
+ $lei->ale->refresh_externals($lxs, $lei);
my $self = bless {
-force_eml => 1, # for LeiInput->input_fh
lxs => $lxs,
my ($op_c, $ops) = $lei->workers_start($self, 1);
$lei->{wq1} = $self;
net_merge_all_done($self) unless $lei->{auth};
- $op_c->op_wait_event($ops);
+ $lei->wait_wq_events($op_c, $ops);
}
sub ipc_atfork_child {
binmode $lei->{1}, ':utf8';
$self->{blobs} = {}; # oidhex => filename
$self->{rdtmp} = File::Temp->newdir('lei-rediff-XXXX', TMPDIR => 1);
- $self->{rmt} = [ map {
+ $self->{tmp_sto} = PublicInbox::LeiStore->new(
+ "$self->{rdtmp}/tmp.store",
+ { creat => { nproc => 1 }, indexlevel => 'medium' });
+ $self->{tmp_sto}->{priv_eidx}->{parallel} = 0;
+ $self->{rmt} = [ $self->{tmp_sto}->search, map {
PublicInbox::LeiRemote->new($lei, $_)
} $self->{lxs}->remotes ];
$self->{gits} = [ map {