From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5CEE01F520 for ; Mon, 26 Sep 2022 10:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1664187436; bh=b4EsgZPOzUeyKx3ag2nBurHuw18a8fs/x7LWdntbywk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=U4CPdpScYxoV8a1JSPpgBqCy/JMvj2iGraF5YMkOD3Q5XR6/IhQvDs7ucf20ZmrYh 1zzt6P0hHVeHLWU/3rF63WSHWl0PNSWsAmmrpC+zt5Nm+8+J5QXNldtp1ChrduGyEc AnxnwAmMncB853bZuB9+1EH1xjUoKEk3Bvnl0pFo= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] gcf2: support worktree $GIT_DIR Date: Mon, 26 Sep 2022 10:17:13 +0000 Message-Id: <20220926101715.1853-3-e@80x24.org> In-Reply-To: <20220926101715.1853-1-e@80x24.org> References: <20220926101715.1853-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Gcf2.pm b/lib/PublicInbox/Gcf2.pm index 02cd0de2..2ba2efff 100644 --- a/lib/PublicInbox/Gcf2.pm +++ b/lib/PublicInbox/Gcf2.pm @@ -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 () { 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)) {