-my $mime = Email::MIME->create(
- header => [
- From => 'a@example.com',
- To => 'b@example.com',
- 'Content-Type' => 'text/plain',
- Subject => 'this is a subject',
- 'Message-ID' => '<a@example.com>',
- ],
- body => "hello world\n",
-);
-like($im->add($mime), qr/\A:\d+\z/, 'added one message');
+$im->init_bare;
+my $mime = PublicInbox::Eml->new(<<'EOF');
+From: a@example.com
+To: b@example.com
+Subject: this is a subject
+Message-ID: <a@example.com>
+Date: Fri, 02 Oct 1993 00:00:00 +0000
+
+hello world
+EOF
+
+my $v2 = require_git(2.6, 1);
+my $smsg = bless {}, 'PublicInbox::Smsg' if $v2;
+like($im->add($mime, undef, $smsg), qr/\A:[0-9]+\z/, 'added one message');
+
+if ($v2) {
+ like($smsg->{blob}, qr/\A[a-f0-9]{40,64}\z/, 'got last object_id');
+ my @cmd = ('git', "--git-dir=$git->{git_dir}", qw(hash-object --stdin));
+ open my $in, '+<', undef or BAIL_OUT "open(+<): $!";
+ print $in $mime->as_string or die "write failed: $!";
+ $in->flush or die "flush failed: $!";
+ seek($in, 0, SEEK_SET) or die "seek: $!";
+ chomp(my $hashed_obj = xqx(\@cmd, undef, { 0 => $in }));
+ is($?, 0, 'hash-object');
+ is($hashed_obj, $smsg->{blob}, "blob object_id matches exp");
+}
+