2 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 eval { require PublicInbox::Gcf2 };
5 die "libgit2 development package or Inline::C missing for $0: $@\n" if $@;
6 my @dirs; # may get big (30K-100K)
7 my $gcf2 = PublicInbox::Gcf2::new();
8 use IO::Handle; # autoflush
14 if (m!\A/!) { # +/path/to/git-dir
16 $gcf2->add_alternate("$_/objects");
17 } elsif (!$gcf2->cat_oid(1, $_)) {
18 # retry once if missing. We only get unabbreviated OIDs
19 # from SQLite or Xapian DBs, here, so malicious clients
20 # can't trigger excessive retries:
22 warn "I: $$ $oid missing, retrying...\n";
24 # clients may need to wait a bit for this:
25 $gcf2 = PublicInbox::Gcf2::new();
26 $gcf2->add_alternate("$_/objects") for @dirs;
28 if ($gcf2->cat_oid(1, $oid)) {
29 warn "I: $$ $oid found after retry\n";
31 warn "W: $$ $oid missing after retry\n";
32 print "$oid missing\n"; # mimic git-cat-file