From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] solver: support sha256 coderepos
Date: Wed, 10 Nov 2021 02:39:00 +0000 [thread overview]
Message-ID: <20211110023900.9273-1-e@80x24.org> (raw)
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: $!";
reply other threads:[~2021-11-10 2:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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: https://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=20211110023900.9273-1-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).