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: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 06A571F403 for ; Sat, 22 Oct 2022 21:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbiJVVSh (ORCPT ); Sat, 22 Oct 2022 17:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbiJVVSe (ORCPT ); Sat, 22 Oct 2022 17:18:34 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD1127C1B5 for ; Sat, 22 Oct 2022 14:18:33 -0700 (PDT) Received: (qmail 21434 invoked by uid 109); 22 Oct 2022 21:18:33 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Sat, 22 Oct 2022 21:18:33 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 4194 invoked by uid 111); 22 Oct 2022 21:18:33 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Sat, 22 Oct 2022 17:18:33 -0400 Authentication-Results: peff.net; auth=none Date: Sat, 22 Oct 2022 17:18:32 -0400 From: Jeff King To: Junio C Hamano Cc: Michael McClimon , git@vger.kernel.org Subject: Re: [PATCH v2 2/2] setup: allow Git.pm to do unsafe repo checking Message-ID: References: <20221016212236.12453-1-michael@mcclimon.org> <20221022011931.43992-1-michael@mcclimon.org> <20221022011931.43992-3-michael@mcclimon.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, Oct 21, 2022 at 10:29:33PM -0700, Junio C Hamano wrote: > I also have to wonder (and this is *not* a suggestion for inventing > an alternative fix for perl/Git.pm) if we were creating perl/Git.pm > from scratch today, we even need to be worried about this issue. We > may have Git::repo_path() helper but if we call it in a natural way > (read: as if an interactive end-user would type commands), it is > likely that we would run "git rev-parse --git-dir" or something > without setting GIT_DIR, and when we need to run "git" command, say > "git diff", we would also run "git diff" as if the end user would > type from within their interactive session and without setting > GIT_DIR, and everything should work. IOW, why do we even setting > and exporting the auto-detected value in GIT_DIR? I think it has to in order to avoid surprises. If I do this: perl -MGit -e ' my $r = Git->repository; chdir("/somewhere/else"); $r->git_command(...); ' that command ought to run in the repository I opened earlier. So I think to keep the illusion of a lib-ified object, creating that object has to lock in the path. But it really seems like we should be asking rev-parse what that path is, not trying to do any magic ourselves. -Peff