sub default_branch () {
state $default_branch = do {
- delete local $ENV{GIT_CONFIG};
- my $r = popen_rd([qw(git config --global init.defaultBranch)]);
+ my $r = popen_rd([qw(git config --global init.defaultBranch)],
+ { GIT_CONFIG => undef });
chomp(my $h = <$r> // '');
close $r;
- $h eq '' ? 'refs/heads/master' : $h;
+ $h eq '' ? 'refs/heads/master' : "refs/heads/$h";
}
}
$smsg->{blob} = $self->get_mark(":$blob");
$smsg->set_bytes($raw_email, $n);
if (my $oidx = delete $smsg->{-oidx}) { # used by LeiStore
- return if $oidx->blob_exists($smsg->{blob});
+ my $eidx_git = delete $smsg->{-eidx_git};
+
+ # we need this sharedkv to dedupe blobs added in the
+ # same fast-import transaction
+ my $u = $self->{uniq_skv} //= do {
+ require PublicInbox::SharedKV;
+ my $x = PublicInbox::SharedKV->new;
+ $x->dbh;
+ $x;
+ };
+ return if !$u->set_maybe($smsg->oidbin, 1);
+ return if (!$oidx->vivify_xvmd($smsg) &&
+ $eidx_git->check($smsg->{blob}));
}
}
my $ref = $self->{ref};
}
my @INIT_FILES = ('HEAD' => undef, # filled in at runtime
- 'description' => <<EOD,
-Unnamed repository; edit this file 'description' to name the repository.
-EOD
'config' => <<EOC);
[core]
repositoryFormatVersion = 0
}
}
-sub digest2mid ($$) {
- my ($dig, $hdr) = @_;
+sub digest2mid ($$;$) {
+ my ($dig, $hdr, $fallback_time) = @_;
my $b64 = $dig->clone->b64digest;
# Make our own URLs nicer:
# See "Base 64 Encoding with URL and Filename Safe Alphabet" in RFC4648
# Add a date prefix to prevent a leading '-' in case that trips
# up some tools (e.g. if a Message-ID were a expected as a
# command-line arg)
- my $dt = msg_datestamp($hdr);
+ my $dt = msg_datestamp($hdr, $fallback_time);
$dt = POSIX::strftime('%Y%m%d%H%M%S', gmtime($dt));
"$dt.$b64" . '@z';
}