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: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 137F21F453 for ; Mon, 29 Apr 2019 20:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729374AbfD2UOV (ORCPT ); Mon, 29 Apr 2019 16:14:21 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:46144 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729363AbfD2UOT (ORCPT ); Mon, 29 Apr 2019 16:14:19 -0400 Received: by mail-ed1-f68.google.com with SMTP id d1so10257738edd.13 for ; Mon, 29 Apr 2019 13:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=CvkHYwybWMLmqCpofAtLBI5feF1IPZB3rdQguZg52VY=; b=JrfSvwxuNeIarkQftKhPzQNKoDqLhlkf83LiCTDacbQMXcBjEpnRSz3n0ApaabuRDP v+P1NP3ZLPupOCHOM36Cn+hrXeKfO/gBaQbRKL7+zRWij+6uaFzUjnkLvJHsn3KvxxTX VzMUuE9enCokzyp4D89Tz2NfZJjYqHpS0M/W7nJCTAql3BJbaY3JBWIzqj36l3hiIyKP f7czm2LQJcZELQdZUwlWMCqUXc18+YkpJ+n3wuls9saLt+Pu5WU4RKot+FvjKTU2f9I3 mZzFLb56gIg7qqo7Oh7/LE+vqn/Gx9sWza4HaPBQmvH65TOSzY+nVsItHc0Q6LmC0AbR bNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=CvkHYwybWMLmqCpofAtLBI5feF1IPZB3rdQguZg52VY=; b=bSOmFoXjuWTVFB4CcRcm/Ma9rejLNYyePkfN66rdzw2P+30Ck9JNLmYRnf9n1sIRGN lDYvq1ZMS0n/qpQhb8J7hhQKrIQ9YxkSu0kB6OXrVlhc+6W0+akEWEWTtA6ttWX/I8LF VbDh1uDaNf8hY6cJTWsrz99zPr6n3BVbGzYSIyIBKPCbCcy2M6QbxOC+NOMrRLiuqzDZ CBjTJF4rwv2MwhQOWfqrVS9eMLtsGp3rDQ1HzBFM3kJ9Z5GSHbFmIz9CtPfBhgmyp+nq VjGTonVNixixVobgpdjlcEFYsVzEQyC3f4fsa19WreJIiRsrtyhsim8cVUNHGP3b00aS o2Mw== X-Gm-Message-State: APjAAAUShfeqwGhNPfPS0974xC5fbuW9qPh9u4ZqxTQUu73e9kN0VPoc p1JzPm9WJFM7Dvq6MQ1oIiVs2GuM X-Google-Smtp-Source: APXvYqxjHBBkDkowu/BOCF6EXPIgBZXGH0bvv58VfgcB5gwoE0wefp/sYkWidFIx1/xqZDghSLSqiA== X-Received: by 2002:a17:906:29c1:: with SMTP id y1mr30564197eje.251.1556568858012; Mon, 29 Apr 2019 13:14:18 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h10sm9652160ede.21.2019.04.29.13.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 13:14:17 -0700 (PDT) Date: Mon, 29 Apr 2019 13:14:17 -0700 (PDT) X-Google-Original-Date: Mon, 29 Apr 2019 20:14:05 GMT Message-Id: In-Reply-To: References: From: "Jeff Hostetler via GitGitGadget" Subject: [PATCH v5 05/11] config: add read_very_early_config() Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, peff@peff.net, jrnieder@gmail.com, steadmon@google.com, avarab@gmail.com, Junio C Hamano , Jeff Hostetler Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jeff Hostetler Created an even lighter version of read_early_config() that only looks at system and global config settings. It omits repo-local, worktree-local, and command-line settings. Signed-off-by: Jeff Hostetler --- config.c | 23 ++++++++++++++++++++--- config.h | 4 ++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/config.c b/config.c index c809f76219..d7a08713a8 100644 --- a/config.c +++ b/config.c @@ -1688,14 +1688,15 @@ static int do_git_config_sequence(const struct config_options *opts, ret += git_config_from_file(fn, user_config, data); current_parsing_scope = CONFIG_SCOPE_REPO; - if (repo_config && !access_or_die(repo_config, R_OK, 0)) + if (!opts->ignore_repo && repo_config && + !access_or_die(repo_config, R_OK, 0)) ret += git_config_from_file(fn, repo_config, data); /* * Note: this should have a new scope, CONFIG_SCOPE_WORKTREE. * But let's not complicate things before it's actually needed. */ - if (repository_format_worktree_config) { + if (!opts->ignore_worktree && repository_format_worktree_config) { char *path = git_pathdup("config.worktree"); if (!access_or_die(path, R_OK, 0)) ret += git_config_from_file(fn, path, data); @@ -1703,7 +1704,7 @@ static int do_git_config_sequence(const struct config_options *opts, } current_parsing_scope = CONFIG_SCOPE_CMDLINE; - if (git_config_from_parameters(fn, data) < 0) + if (!opts->ignore_cmdline && git_config_from_parameters(fn, data) < 0) die(_("unable to parse command-line config")); current_parsing_scope = CONFIG_SCOPE_UNKNOWN; @@ -1794,6 +1795,22 @@ void read_early_config(config_fn_t cb, void *data) strbuf_release(&gitdir); } +/* + * Read config but only enumerate system and global settings. + * Omit any repo-local, worktree-local, or command-line settings. + */ +void read_very_early_config(config_fn_t cb, void *data) +{ + struct config_options opts = { 0 }; + + opts.respect_includes = 1; + opts.ignore_repo = 1; + opts.ignore_worktree = 1; + opts.ignore_cmdline = 1; + + config_with_options(cb, data, NULL, &opts); +} + static struct config_set_element *configset_find_element(struct config_set *cs, const char *key) { struct config_set_element k; diff --git a/config.h b/config.h index ee5d3fa7b4..6a58d61d22 100644 --- a/config.h +++ b/config.h @@ -55,6 +55,9 @@ typedef int (*config_parser_event_fn_t)(enum config_event_t type, struct config_options { unsigned int respect_includes : 1; + unsigned int ignore_repo : 1; + unsigned int ignore_worktree : 1; + unsigned int ignore_cmdline : 1; const char *commondir; const char *git_dir; config_parser_event_fn_t event_fn; @@ -83,6 +86,7 @@ extern int git_config_from_blob_oid(config_fn_t fn, const char *name, extern void git_config_push_parameter(const char *text); extern int git_config_from_parameters(config_fn_t fn, void *data); extern void read_early_config(config_fn_t cb, void *data); +extern void read_very_early_config(config_fn_t cb, void *data); extern void git_config(config_fn_t fn, void *); extern int config_with_options(config_fn_t fn, void *, struct git_config_source *config_source, -- gitgitgadget