From: Eric Wong (Contractor, The Linux Foundation) <e@80x24.org>
Date: Sun, 9 Jun 2019 00:53:29 +0000 (+0000)
Subject: git: ensure ->modified returns an integer
X-Git-Tag: v1.2.0~178^2
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d3c94cf92e8a4693aa691f3464c94c00be543cfc;p=public-inbox.git

git: ensure ->modified returns an integer

We don't want to serialize timestamps as strings to JSON.
I only noticed this bug on a 32-bit system.
---

diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 68445b3c..82510b99 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -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;
diff --git a/t/www_listing.t b/t/www_listing.t
index 2741e1b8..1f292980 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -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');