about summary refs log tree commit homepage
path: root/lib/PublicInbox/Import.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-04-19 21:54:48 +0000
committerEric Wong <e@80x24.org>2023-04-20 18:22:55 +0000
commitcbd13f06bf17357a9e160a6ae54a3f532e9eb068 (patch)
treeb90607adbd26eccdafa656046c82d4d83767d9a4 /lib/PublicInbox/Import.pm
parentc0d0d5b4131e5b18e0d5ae9877460204a8cd2f3c (diff)
downloadpublic-inbox-cbd13f06bf17357a9e160a6ae54a3f532e9eb068.tar.gz
This special support is only needed for --prune at the moment
since the indexing side works on a per-repo basis.  There's no
automated tests, yet, but it seems to work well on my sha256
projects when sharing a cindex with sha1 projects.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r--lib/PublicInbox/Import.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 39719bcb..59462e9a 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -461,13 +461,21 @@ my @INIT_FILES = ('HEAD' => undef, # filled in at runtime
 EOC
 
 sub init_bare {
-        my ($dir, $head) = @_; # or self
+        my ($dir, $head, $fmt) = @_; # or self
         $dir = $dir->{git}->{git_dir} if ref($dir);
         require File::Path;
         File::Path::make_path(map { $dir.$_ } qw(/objects/info /refs/heads));
         $INIT_FILES[1] //= 'ref: '.default_branch."\n";
         my @fn_contents = @INIT_FILES;
         $fn_contents[1] = "ref: refs/heads/$head\n" if defined $head;
+        $fn_contents[3] = <<EOM if defined($fmt) && $fmt ne 'sha1';
+[core]
+        repositoryFormatVersion = 1
+        filemode = true
+        bare = true
+[extensions]
+        objectFormat = $fmt
+EOM
         while (my ($fn, $contents) = splice(@fn_contents, 0, 2)) {
                 my $f = $dir.'/'.$fn;
                 next if -f $f;