From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 151C720C4C for ; Mon, 12 Jun 2017 21:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752789AbdFLVec (ORCPT ); Mon, 12 Jun 2017 17:34:32 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:33762 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752735AbdFLVea (ORCPT ); Mon, 12 Jun 2017 17:34:30 -0400 Received: by mail-pf0-f170.google.com with SMTP id 83so56874669pfr.0 for ; Mon, 12 Jun 2017 14:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J6K+Ubav88KP/yl4TewJl8DygBu3nJYxgrXnVLQKnYQ=; b=O1xlRVDJNhRCjAMFYceAd6nB7B+Eb8A1k/jeEPds51GXZpwiR9K8HLstUKh00tEynR h4MdyKazMgu1STh78fjnNLGVeF7c9/edDg3SITHmsZVjWirnUP3jw/6VLaSxdAq4Xte0 9MCXR3dR9rUrKdr9k5p4eJP/wz//rfK3hUrH+4LTU+r8HxKOqnpyCPEQczNRhqLlum9K fHYRPzkZ5miRA1zIvMaZkPcDdI6drVS1szXx0d0ID0FendJVMQ7xHH38o2lFI96F4ETX WwsTnlbRCVOrq9LvCFTWg0ekN2glHml0huep5I7P4tWTYj4Lztv0gRCKPkkBc4d9SKxp WvBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J6K+Ubav88KP/yl4TewJl8DygBu3nJYxgrXnVLQKnYQ=; b=tIhTNLbgt0ct3we3GkeOIxsYJMzilIYAOU6gCnZglcR+XNdCTza0Cd3lYc2LEKo/GY SbPdQ3nRflxlictZaJVMvb7I7s8A816v2WzR9cLftuXK0YIKp/S8IDUHczzb6JqILgO5 +BQGOK2P96eb/wmDBk7GSTnPT5TUx+N6IPPCJx7+i2IbkKKNwiBU6UcIbyBfd25ceJMM I9WMdX7ekwnAHE1UtaT80hGiLySNigjEKnQ0kNwTUH3lQ+9RI+OGMBielAM2LkzXAfQQ CikUPwbVz3ZYrL4m6ZSITaXbxbPfa1GVC1lj3hDD0Pq0r3ULVAyL3pJqD4Bhf9a9Aud/ ZCBA== X-Gm-Message-State: AODbwcBcQw/J1ai16rdNkdg+0xxadOT5vjCUTAX2dKQDuKZeAJ/pBDl3 gVnBq6f9b4sS5tFbbrL3Gw== X-Received: by 10.84.212.137 with SMTP id e9mr59885169pli.115.1497303269224; Mon, 12 Jun 2017 14:34:29 -0700 (PDT) Received: from roshar.svl.corp.google.com ([100.96.218.30]) by smtp.gmail.com with ESMTPSA id v21sm13333468pfk.75.2017.06.12.14.34.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Jun 2017 14:34:28 -0700 (PDT) From: Brandon Williams To: git@vger.kernel.org Cc: peff@peff.net, gitster@pobox.com, jrnieder@gmail.com, Brandon Williams Subject: [PATCH 4/4] config: don't implicitly use gitdir Date: Mon, 12 Jun 2017 14:34:06 -0700 Message-Id: <20170612213406.83247-5-bmwill@google.com> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170612213406.83247-1-bmwill@google.com> References: <20170612213406.83247-1-bmwill@google.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Commit 2185fde56 (config: handle conditional include when $GIT_DIR is not set up) added a 'git_dir' field to the config_options struct. Let's use this option field explicitly all the time instead of occasionally falling back to calling 'git_pathdup("config")' to get the path to the local repository configuration. This allows 'do_git_config_sequence()' to not implicitly rely on global repository state. Signed-off-by: Brandon Williams --- builtin/config.c | 2 ++ config.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/config.c b/builtin/config.c index 753c40a5c..90f49a6ee 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -539,6 +539,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) config_options.respect_includes = !given_config_source.file; else config_options.respect_includes = respect_includes_opt; + if (have_git_dir()) + config_options.git_dir = get_git_common_dir(); if (end_null) { term = '\0'; diff --git a/config.c b/config.c index 2390f98e3..4e2842689 100644 --- a/config.c +++ b/config.c @@ -219,8 +219,6 @@ static int include_by_gitdir(const struct config_options *opts, if (opts->git_dir) git_dir = opts->git_dir; - else if (have_git_dir()) - git_dir = get_git_dir(); else goto done; @@ -1548,8 +1546,6 @@ static int do_git_config_sequence(const struct config_options *opts, if (opts->git_dir) repo_config = mkpathdup("%s/config", opts->git_dir); - else if (have_git_dir()) - repo_config = git_pathdup("config"); else repo_config = NULL; @@ -1613,6 +1609,8 @@ static void git_config_raw(config_fn_t fn, void *data) struct config_options opts = {0}; opts.respect_includes = 1; + if (have_git_dir()) + opts.git_dir = get_git_common_dir(); if (git_config_with_options(fn, data, NULL, &opts) < 0) /* * git_config_with_options() normally returns only -- 2.13.1.518.g3df882009-goog