$self->{out} = $out_w;
$self->{lockfh} = $lockfh;
$self->{pid} = $pid;
+ $self->{nchg} = 0;
($in_r, $out_w);
}
$day, $t[3], $mon, $t[5] + 1900, $t[2], $t[1], $t[0]);
}
+sub norm_body ($) {
+ my ($mime) = @_;
+ my $b = $mime->body_raw;
+ $b =~ s/(\r?\n)+\z//s;
+ $b
+}
+
# returns undef on non-existent
# ('MISMATCH', msg) on mismatch
# (:MARK, msg) on success
die "bad read on final byte: <$lf>" if $lf ne "\n";
my $cur = Email::MIME->new($buf);
if ($cur->header('Subject') ne $mime->header('Subject') ||
- $cur->body ne $mime->body) {
+ norm_body($cur) ne norm_body($mime)) {
return ('MISMATCH', $cur);
}
"data 3\nrm\n\n",
'from ', ($parent ? $parent : $tip), "\n" or wfail;
print $w "D $path\n\n" or wfail;
+ $self->{nchg}++;
(($self->{tip} = ":$commit"), $cur);
}
# "'A U Thor <u@example.com>' via foo" <foo@example.com>
# ref:
# <CAD0k6qSUYANxbjjbE4jTW4EeVwOYgBD=bXkSu=akiYC_CB7Ffw@mail.gmail.com>
- $name =~ s/<([^>]+)>/($1)/g;
+ $name =~ tr/<>// and $name = $email;
my ($r, $w) = $self->gfi_start;
my $tip = $self->{tip};
print $w 'from ', ($parent ? $parent : $tip), "\n" or wfail;
}
print $w "M 100644 :$blob $path\n\n" or wfail;
+ $self->{nchg}++;
$self->{tip} = ":$commit";
}
my $pid = delete $self->{pid} or die 'BUG: missing {pid} when done';
waitpid($pid, 0) == $pid or die 'fast-import did not finish';
$? == 0 or die "fast-import failed: $?";
+ my $nchg = delete $self->{nchg};
# for compatibility with existing ssoma installations
# we can probably remove this entirely by 2020
my $git_dir = $self->{git}->{git_dir};
- my $index = "$git_dir/ssoma.index";
# XXX: change the following scope to: if (-e $index) # in 2018 or so..
my @cmd = ('git', "--git-dir=$git_dir");
- unless ($ENV{FAST}) {
+ if ($nchg && !$ENV{FAST}) {
+ my $index = "$git_dir/ssoma.index";
my $env = { GIT_INDEX_FILE => $index };
my @rt = (@cmd, qw(read-tree -m -v -i), $self->{ref});
$pid = spawn(\@rt, $env, undef);
waitpid($pid, 0) == $pid or die 'read-tree did not finish';
$? == 0 or die "failed to update $git_dir/ssoma.index: $?\n";
}
-
- $pid = spawn([@cmd, 'update-server-info'], undef, undef);
- defined $pid or die "spawn update-server-info failed: $!\n";
- waitpid($pid, 0) == $pid or die 'update-server-info did not finish';
- $? == 0 or die "failed to update-server-info: $?\n";
+ if ($nchg) {
+ $pid = spawn([@cmd, 'update-server-info'], undef, undef);
+ defined $pid or die "spawn update-server-info failed: $!\n";
+ waitpid($pid, 0) == $pid or
+ die 'update-server-info did not finish';
+ $? == 0 or die "failed to update-server-info: $?\n";
+ }
my $lockfh = delete $self->{lockfh} or die "BUG: not locked: $!";
flock($lockfh, LOCK_UN) or die "unlock failed: $!";