From 375b3ccfd3ca978281cb3869b62fc91eebc60d6e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 15 Sep 2021 11:26:17 +0000 Subject: multi_git: hoist out common epoch/alternates handling IMHO, this greatly improves code sharing and organization between v2, extindex, and lei/store. Common git-related logic for these is lightly-refactored and easier to reason about. The impetus for this big change was to ensure inboxes created+managed by public-inbox-{clone,fetch} could have alternates and configs setup properly without depending on SQLite (via V2Writable). This change does that while making old code shorter and better factored. --- t/lei-mirror.t | 15 ++++++++++++++- t/v2mirror.t | 9 ++++++--- t/v2writable.t | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 't') diff --git a/t/lei-mirror.t b/t/lei-mirror.t index 44acbe95..5238b67c 100644 --- a/t/lei-mirror.t +++ b/t/lei-mirror.t @@ -95,7 +95,20 @@ SKIP: { ok(run_script([qw(-clone -q -C), $d, "$http/t2"], undef, $opt), '-clone succeeds on v2'); - ok(-d "$d/t2/git/0.git", 'epoch cloned'); + ok(-f "$d/t2/git/0.git/config", 'epoch cloned'); + + # writeBitmaps is the default for bare repos in git 2.22+, + # so we may stop setting it ourselves. + 0 and is(xqx(['git', "--git-dir=$d/t2/git/0.git", 'config', + qw(--bool repack.writeBitmaps)]), "true\n", + 'write bitmaps set (via include.path=all.git/config'); + + is(xqx(['git', "--git-dir=$d/t2/git/0.git", 'config', + qw(include.path)]), "../../all.git/config\n", + 'include.path set'); + + ok(-s "$d/t2/all.git/objects/info/alternates", + 'all.git alternates created'); ok(-f "$d/t2/manifest.js.gz", 'manifest saved'); ok(!-e "$d/t2/mirror.done", 'no leftover mirror.done'); ok(run_script([qw(-fetch -C), "$d/t2"], undef, $opt), diff --git a/t/v2mirror.t b/t/v2mirror.t index 8bcffc29..54ad6945 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -228,10 +228,13 @@ EOF is(scalar($mset->items), 0, 'large message not re-indexed'); } ok(scalar(@new_epochs), 'new epochs were created and fetched'); +for my $d (@new_epochs) { + is(xqx(['git', "--git-dir=$d", 'config', qw(include.path)]), + "../../all.git/config\n", + 'include.path set'); +} ok($td->kill, 'killed httpd'); $td->join; -done_testing(); - -1; +done_testing; diff --git a/t/v2writable.t b/t/v2writable.t index d9e7b980..477621e2 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -308,7 +308,7 @@ ok($@, 'V2Writable fails on non-existent dir'); open $fh, '<', $alt or die $!; my $before = do { local $/; <$fh> }; - ok($v2w->git_init(3), 'init a new epoch'); + ok($v2w->{mg}->add_epoch(3), 'init a new epoch'); open $fh, '<', $alt or die $!; my $after = do { local $/; <$fh> }; ok(index($after, $before) > 0, -- cgit v1.2.3-24-ge0c7