about summary refs log tree commit
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-26 23:41:02 +0000
committerEric Wong <e@yhbt.net>2020-01-28 03:00:42 +0000
commit8122bd3803b7520ab5421df264406e670e3f902b (patch)
tree79684c51448c7c233dc89cab0a8b9ea7a9a61eca /t
parent436f9dfcd3e3d3e65cb882fd518634d9f95ac19c (diff)
downloadpublic-inbox-8122bd3803b7520ab5421df264406e670e3f902b.tar.gz
New epochs are the most likely to have loose objects.  git won't
be able to take advantage of pack indices and needs to scan
every alternate for the loose object via open/openat syscalls.
Those syscalls will add up some day when we've got hundreds or
thousands of epochs.
Diffstat (limited to 't')
-rw-r--r--t/v2writable.t24
1 files changed, 24 insertions, 0 deletions
diff --git a/t/v2writable.t b/t/v2writable.t
index 63f27f96..7ceaa6e4 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -284,4 +284,28 @@ eval {
 };
 ok($@, 'V2Writable fails on non-existent dir');
 
+{
+        my $v2w = PublicInbox::V2Writable->new($tmp, 1);
+        ok($v2w, 'creat flag works');
+        $v2w->{parallel} = 0;
+        $v2w->init_inbox(0);
+        my $alt = "$tmp->{inboxdir}/all.git/objects/info/alternates";
+        open my $fh, '>>', $alt or die $!;
+        print $fh "$inboxdir/all.git/objects\n" or die $!;
+        chmod(0664, $fh) or die "fchmod: $!";
+        close $fh or die $!;
+        open $fh, '<', $alt or die $!;
+        my $before = do { local $/; <$fh> };
+
+        ok($v2w->git_init(3), 'init a new epoch');
+        open $fh, '<', $alt or die $!;
+        my $after = do { local $/; <$fh> };
+        ok(index($after, $before) > 0,
+                'old contents preserved after adding epoch');
+        like($after, qr!\A[^\n]+?/3\.git/objects\n!s,
+                'first line is newest epoch');
+        my $mode = (stat($alt))[2] & 07777;
+        is($mode, 0664, sprintf('0%03o', $mode).' is 0664');
+}
+
 done_testing();