]> Sergey Matveev's repositories - public-inbox.git/commitdiff
gcf2: support worktree $GIT_DIR
authorEric Wong <e@80x24.org>
Mon, 26 Sep 2022 10:17:13 +0000 (10:17 +0000)
committerEric Wong <e@80x24.org>
Mon, 26 Sep 2022 19:22:03 +0000 (19:22 +0000)
We must use `git rev-parse --git-path objects' instead of
blindly appending '/objects' to $GIT_DIR, since appending
doesn't work when $GIT_DIR is a worktree.

lib/PublicInbox/Gcf2.pm

index 02cd0de2b72a40749949028272ab7c41de863ad8..2ba2efffd2d9191b52578f7814cae7418eeabbd6 100644 (file)
@@ -80,7 +80,8 @@ EOM
 }
 
 sub add_alt ($$) {
-       my ($gcf2, $objdir) = @_;
+       my ($gcf2, $git_dir) = @_;
+       my $objdir = PublicInbox::Git->new($git_dir)->git_path('objects');
 
        # libgit2 (tested 0.27.7+dfsg.1-0.2 and 0.28.3+dfsg.1-1~bpo10+1
        # in Debian) doesn't handle relative epochs properly when nested
@@ -120,7 +121,7 @@ sub loop (;$) {
        while (<STDIN>) {
                chomp;
                my ($oid, $git_dir) = split(/ /, $_, 2);
-               $seen{$git_dir} //= add_alt($gcf2, "$git_dir/objects");
+               $seen{$git_dir} //= add_alt($gcf2, $git_dir);
                if (!$gcf2->cat_oid(1, $oid)) {
                        # retry once if missing.  We only get unabbreviated OIDs
                        # from SQLite or Xapian DBs, here, so malicious clients
@@ -128,7 +129,7 @@ sub loop (;$) {
                        warn "I: $$ $oid missing, retrying in $git_dir\n";
 
                        $gcf2 = new();
-                       %seen = ($git_dir => add_alt($gcf2,"$git_dir/objects"));
+                       %seen = ($git_dir => add_alt($gcf2, $git_dir);
                        $check_at = clock_gettime(CLOCK_MONOTONIC) + $exp;
 
                        if ($gcf2->cat_oid(1, $oid)) {