user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/2] v2writable: hoist out fill_alternates
Date: Fri,  8 Mar 2019 22:52:16 +0000	[thread overview]
Message-ID: <20190308225217.31766-2-e@80x24.org> (raw)
In-Reply-To: <20190308225217.31766-1-e@80x24.org>

We'll be using this sub to fill $GIT_DIR/objects/info/alternates
if somebody uses clone --mirror, too
---
 lib/PublicInbox/V2Writable.pm | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index b1d8095..bc31ffa 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -509,14 +509,12 @@ sub done {
 	$self->{-inbox}->git->cleanup;
 }
 
-sub git_init {
+sub fill_alternates ($$) {
 	my ($self, $epoch) = @_;
-	my $pfx = "$self->{-inbox}->{mainrepo}/git";
-	my $git_dir = "$pfx/$epoch.git";
-	my @cmd = (qw(git init --bare -q), $git_dir);
-	PublicInbox::Import::run_die(\@cmd);
 
+	my $pfx = "$self->{-inbox}->{mainrepo}/git";
 	my $all = "$self->{-inbox}->{mainrepo}/all.git";
+	my @cmd;
 	unless (-d $all) {
 		@cmd = (qw(git init --bare -q), $all);
 		PublicInbox::Import::run_die(\@cmd);
@@ -524,8 +522,7 @@ sub git_init {
 				'repack.writeBitmaps', 'true');
 		PublicInbox::Import::run_die(\@cmd);
 	}
-
-	@cmd = (qw/git config/, "--file=$git_dir/config",
+	@cmd = (qw/git config/, "--file=$pfx/$epoch.git/config",
 			'include.path', '../../all.git/config');
 	PublicInbox::Import::run_die(\@cmd);
 
@@ -540,12 +537,20 @@ sub git_init {
 		my $dir = "../../git/$i.git/objects";
 		push @add, $dir if !$alts{$dir} && -d "$pfx/$i.git";
 	}
-	return $git_dir unless @add;
+	return unless @add;
 	open my $fh, '>>', $alt or die "open >> $alt: $!\n";
 	foreach my $dir (@add) {
 		print $fh "$dir\n" or die "print >> $alt: $!\n";
 	}
 	close $fh or die "close $alt: $!\n";
+}
+
+sub git_init {
+	my ($self, $epoch) = @_;
+	my $git_dir = "$self->{-inbox}->{mainrepo}/git/$epoch.git";
+	my @cmd = (qw(git init --bare -q), $git_dir);
+	PublicInbox::Import::run_die(\@cmd);
+	fill_alternates($self, $epoch);
 	$git_dir
 }
 
-- 
EW


  reply	other threads:[~2019-03-08 22:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08 22:52 [PATCH 0/2] make "public-inbox-index" friendlier to clone mirrors Eric Wong
2019-03-08 22:52 ` Eric Wong [this message]
2019-03-08 22:52 ` [PATCH 2/2] v2writable: index_sync adds new epochs to alternates Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190308225217.31766-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).