]> Sergey Matveev's repositories - public-inbox.git/commitdiff
another step towards git SHA-256 support
authorEric Wong <e@80x24.org>
Thu, 20 Oct 2022 08:43:10 +0000 (08:43 +0000)
committerEric Wong <e@80x24.org>
Mon, 24 Oct 2022 08:18:26 +0000 (08:18 +0000)
While SHA-256 isn't supported for inboxes, yet
xt/git-http-backend.t now runs properly against a SHA-256 code
repository

lib/PublicInbox/GitHTTPBackend.pm
t/git.t
t/import.t
t/mda.t
xt/git-http-backend.t

index 3aae54548dc990fef9e93e0e751a7fc7e782664a..72b8e6c3403f4db6edaebf2c089396f144c73a4e 100644 (file)
@@ -23,10 +23,8 @@ my @text = qw[HEAD info/refs info/attributes
        objects/info/(?:http-alternates|alternates|packs)
        cloneurl description];
 
-my @binary = qw!
-       objects/[a-f0-9]{2}/[a-f0-9]{38}
-       objects/pack/pack-[a-f0-9]{40}\.(?:pack|idx)
-       !;
+my @binary = ('objects/[a-f0-9]{2}/[a-f0-9]{38,62}',
+       'objects/pack/pack-[a-f0-9]{40,64}\.(?:pack|idx)');
 
 our $ANY = join('|', @binary, @text, 'git-upload-pack');
 my $BIN = join('|', @binary);
@@ -62,13 +60,13 @@ sub serve_dumb {
 
        my $h = [];
        my $type;
-       if ($path =~ m!\Aobjects/[a-f0-9]{2}/[a-f0-9]{38}\z!) {
+       if ($path =~ m!\Aobjects/[a-f0-9]{2}/[a-f0-9]{38,62}\z!) {
                $type = 'application/x-git-loose-object';
                cache_one_year($h);
-       } elsif ($path =~ m!\Aobjects/pack/pack-[a-f0-9]{40}\.pack\z!) {
+       } elsif ($path =~ m!\Aobjects/pack/pack-[a-f0-9]{40,64}\.pack\z!) {
                $type = 'application/x-git-packed-objects';
                cache_one_year($h);
-       } elsif ($path =~ m!\Aobjects/pack/pack-[a-f0-9]{40}\.idx\z!) {
+       } elsif ($path =~ m!\Aobjects/pack/pack-[a-f0-9]{40,64}\.idx\z!) {
                $type = 'application/x-git-packed-objects-toc';
                cache_one_year($h);
        } elsif ($path =~ /\A(?:$TEXT)\z/o) {
diff --git a/t/git.t b/t/git.t
index 56fc8d953f01d548b2f67e6655d3b06214f5ed1f..d8957e422fd31083815fa46f6df9dfd166fc0d5b 100644 (file)
--- a/t/git.t
+++ b/t/git.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use Test::More;
@@ -44,7 +44,7 @@ use PublicInbox::Git;
        my $f = 'HEAD:foo.txt';
        my @x = $gcf->check($f);
        is(scalar @x, 3, 'returned 3 element array for existing file');
-       like($x[0], qr/\A[a-f0-9]{40}\z/, 'returns obj ID in 1st element');
+       like($x[0], qr/\A[a-f0-9]{40,64}\z/, 'returns obj ID in 1st element');
        is('blob', $x[1], 'returns obj type in 2nd element');
        like($x[2], qr/\A\d+\z/, 'returns obj size in 3rd element');
 
index ae76858ba2ab7827bc7aaa1d45db377a0954ee64..4ba740224aa9f1f4e025ab1f9e8bb7eda3e223ec 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
@@ -30,7 +30,7 @@ my $smsg = bless {}, 'PublicInbox::Smsg' if $v2;
 like($im->add($mime, undef, $smsg), qr/\A:[0-9]+\z/, 'added one message');
 
 if ($v2) {
-       like($smsg->{blob}, qr/\A[a-f0-9]{40}\z/, 'got last object_id');
+       like($smsg->{blob}, qr/\A[a-f0-9]{40,64}\z/, 'got last object_id');
        my @cmd = ('git', "--git-dir=$git->{git_dir}", qw(hash-object --stdin));
        open my $in, '+<', undef or BAIL_OUT "open(+<): $!";
        print $in $mime->as_string or die "write failed: $!";
diff --git a/t/mda.t b/t/mda.t
index d20cdb92be30fb8b962dac42585b1e7204c627ee..e3c5cdff2603871d52845c4d0dccdc64f0019a69 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
@@ -97,7 +97,7 @@ EOF
                local $ENV{PATH} = $main_path;
                ok(run_script(['-mda'], undef, { 0 => \$in }));
                my $rev = $git->qx(qw(rev-list HEAD));
-               like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
+               like($rev, qr/\A[a-f0-9]{40,64}/, "good revision committed");
                chomp $rev;
                my $cmt = $git->cat_file($rev);
                like($$cmt, qr/^author Me <me\@example\.com> 0 \+0000\n/m,
index adadebb0a15ab7926923d736d5ea34c1282262c2..1f3ba0633429856e478fa28f90749e0cbc4dcf00 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Ensure buffering behavior in -httpd doesn't cause runaway memory use
@@ -53,7 +53,7 @@ SKIP: {
                }
        }
        skip "no packs found in $git_dir" unless defined $pack;
-       if ($pack !~ m!(/objects/pack/pack-[a-f0-9]{40}.pack)\z!) {
+       if ($pack !~ m!(/objects/pack/pack-[a-f0-9]{40,64}.pack)\z!) {
                skip "bad pack name: $pack";
        }
        my $url = $1;