From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 354AA1F47D for ; Tue, 21 Mar 2023 23:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1679440064; bh=Iy7ZlkwhlnE3zmQL2H2nFJJdU7UawhDgAFHK0nkf81k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JuL0+FDR8sdp4aeBYLrFbUSWKsYdi2ewBm9nHFF0gpXYIZWH+BPNb0xBMT0tE4HXK 8FN1UZzZ9p9m4Y73K2zQE1D9yyakCIzQhu6jWtOZWRlCDoSakxq88P38GaFpztMpCu DSquhU08w+9XWRUo4O337FToDCUOyOvkZt02tPkY= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/28] admin: ensure resolved GIT_DIR is absolute Date: Tue, 21 Mar 2023 23:07:19 +0000 Message-Id: <20230321230743.3020032-4-e@80x24.org> In-Reply-To: <20230321230743.3020032-1-e@80x24.org> References: <20230321230701.3019936-1-e@80x24.org> <20230321230743.3020032-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We'll also support the $base arg of File::Spec->rel2abs since it should make codesearch indexing easier. --- lib/PublicInbox/Admin.pm | 4 +++- lib/PublicInbox/Config.pm | 2 +- script/public-inbox-convert | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm index b34f2256..abfcbb9c 100644 --- a/lib/PublicInbox/Admin.pm +++ b/lib/PublicInbox/Admin.pm @@ -82,7 +82,9 @@ sub resolve_git_dir { my $dir = do { local $/; <$fh> }; close $fh or die "error in @$cmd (cwd:${\($cd // '.')}): $?\n"; chomp $dir; - rel2abs_collapsed($dir eq '.' ? ($cd // $dir) : $dir); + # --absolute-git-dir requires git v2.13.0+ + $dir = rel2abs_collapsed($dir, $cd) if $dir !~ m!\A/!; + $dir; } # for unconfigured inboxes diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 4065b256..e095ecd1 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -371,7 +371,7 @@ sub git_bool { # is sufficient and doesn't leave "/.." or "/../" sub rel2abs_collapsed { require File::Spec; - my $p = File::Spec->rel2abs($_[-1]); + my $p = File::Spec->rel2abs(@_); return $p if substr($p, -3, 3) ne '/..' && index($p, '/../') < 0; require Cwd; Cwd::abs_path($p); diff --git a/script/public-inbox-convert b/script/public-inbox-convert index 42955a48..5f4f2020 100755 --- a/script/public-inbox-convert +++ b/script/public-inbox-convert @@ -75,7 +75,7 @@ if ($opt->{'index'}) { } local %ENV = (%$env, %ENV) if $env; my $new = { %$old }; -$new->{inboxdir} = $cfg->rel2abs_collapsed($new_dir); +$new->{inboxdir} = PublicInbox::Config::rel2abs_collapsed($new_dir); $new->{version} = 2; $new = PublicInbox::InboxWritable->new($new, { nproc => $opt->{jobs} }); $new->{-no_fsync} = 1 if !$opt->{fsync};