unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] solver: support sha256 coderepos
@ 2021-11-10  2:39 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-11-10  2:39 UTC (permalink / raw)
  To: meta

Tested manually on a newish project I'm working on.
---
 lib/PublicInbox/Git.pm       |  7 +++++++
 lib/PublicInbox/SolverGit.pm | 11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 309f80db..54ceaf0b 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -94,6 +94,13 @@ sub alternates_changed {
 	$self->{alt_st} = $st; # always a true value
 }
 
+sub object_format {
+	$_[0]->{object_format} //= do {
+		my $fmt = $_[0]->qx(qw(config extensions.objectformat));
+		$fmt eq "sha256\n" ? \'sha256' : \undef;
+	}
+}
+
 sub last_check_err {
 	my ($self) = @_;
 	my $fh = $self->{err_c} or return;
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index 5d5060f4..62b5a343 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -293,14 +293,21 @@ sub do_git_init ($) {
 		mkdir("$git_dir/$_") or die "mkdir $_: $!";
 	}
 	open my $fh, '>', "$git_dir/config" or die "open git/config: $!";
-	print $fh <<'EOF' or die "print git/config $!";
+	my $first = $self->{gits}->[0];
+	my $fmt = $first->object_format;
+	my $v = defined($$fmt) ? 1 : 0;
+	print $fh <<EOF or die "print git/config $!";
 [core]
-	repositoryFormatVersion = 0
+	repositoryFormatVersion = $v
 	filemode = true
 	bare = false
 	fsyncObjectfiles = false
 	logAllRefUpdates = false
 EOF
+	print $fh <<EOM if defined($$fmt);
+[extensions]
+	objectformat = $$fmt
+EOM
 	close $fh or die "close git/config: $!";
 
 	open $fh, '>', "$git_dir/HEAD" or die "open git/HEAD: $!";

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-10  2:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10  2:39 [PATCH] solver: support sha256 coderepos Eric Wong

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).