]> Sergey Matveev's repositories - public-inbox.git/commitdiff
git: ensure ->modified returns an integer
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Sun, 9 Jun 2019 00:53:29 +0000 (00:53 +0000)
committerEric Wong <e@80x24.org>
Mon, 10 Jun 2019 04:58:04 +0000 (04:58 +0000)
We don't want to serialize timestamps as strings to JSON.
I only noticed this bug on a 32-bit system.

lib/PublicInbox/Git.pm
t/www_listing.t

index 68445b3cc28961379e763908e8b93b9d5f8e061a..82510b99641200bd014ffdc9d6a537ae22775220 100644 (file)
@@ -320,7 +320,7 @@ sub modified ($) {
                chomp $oid;
                my $buf = cat_file($self, $oid) or next;
                $$buf =~ /^committer .*?> ([0-9]+) [\+\-]?[0-9]+/sm or next;
-               my $cmt_time = $1;
+               my $cmt_time = $1 + 0;
                $modified = $cmt_time if $cmt_time > $modified;
        }
        $modified || time;
index 2741e1b8b531db17084b5c2ed0bb3ff51e5bb8bd..1f2929808f54c21ab1dd73ddda4a7f600608029a 100644 (file)
@@ -96,6 +96,7 @@ SKIP: {
                $body .= $buf;
        }
        IO::Uncompress::Gunzip::gunzip(\$body => \$tmp);
+       unlike($tmp, qr/"modified":\s*"/, 'modified is an integer');
        my $manifest = $json->decode($tmp);
        ok(my $clone = $manifest->{'/alt'}, '/alt in manifest');
        is($clone->{owner}, 'lorelei', 'owner set');