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=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE 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 4A14A1F463 for ; Tue, 10 Dec 2019 11:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727159AbfLJLQs (ORCPT ); Tue, 10 Dec 2019 06:16:48 -0500 Received: from smtp.hosts.co.uk ([85.233.160.19]:25240 "EHLO smtp.hosts.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbfLJLQr (ORCPT ); Tue, 10 Dec 2019 06:16:47 -0500 Received: from [92.30.123.115] (helo=[192.168.1.22]) by smtp.hosts.co.uk with esmtpa (Exim) (envelope-from ) id 1iedVU-0003fx-5C; Tue, 10 Dec 2019 11:16:45 +0000 Subject: Re: [PATCH 2/6] config: add string mapping for enum config_scope To: Emily Shaffer , git@vger.kernel.org References: <20191210023335.49987-1-emilyshaffer@google.com> <20191210023335.49987-3-emilyshaffer@google.com> Cc: "Matthew Rogers mattr94"@gmail.com From: Philip Oakley Message-ID: Date: Tue, 10 Dec 2019 11:16:44 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191210023335.49987-3-emilyshaffer@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Emily, On 10/12/2019 02:33, Emily Shaffer wrote: > If a user is interacting with their config files primarily by the 'git > config' command, using the location flags (--global, --system, etc) then > they may be more interested to see the scope of the config file they are > editing, rather than the filepath. There's asimilar issue being worked on under Git-for-Windows with some proposed code for this very 'problem' https://github.com/git-for-windows/git/pull/2399 and a GitGitGadget PR https://github.com/gitgitgadget/git/pull/478 cc'ing Matthew to help coordination. Philip > > Signed-off-by: Emily Shaffer > --- > config.c | 17 +++++++++++++++++ > config.h | 1 + > 2 files changed, 18 insertions(+) > > diff --git a/config.c b/config.c > index e7052b3977..a20110e016 100644 > --- a/config.c > +++ b/config.c > @@ -3312,6 +3312,23 @@ enum config_scope current_config_scope(void) > return current_parsing_scope; > } > > +const char *config_scope_to_string(enum config_scope scope) > +{ > + switch (scope) { > + case CONFIG_SCOPE_SYSTEM: > + return _("system"); > + case CONFIG_SCOPE_GLOBAL: > + return _("global"); > + case CONFIG_SCOPE_REPO: > + return _("repo"); > + case CONFIG_SCOPE_CMDLINE: > + return _("cmdline"); > + case CONFIG_SCOPE_UNKNOWN: > + default: > + return _("unknown"); > + } > +} > + > int lookup_config(const char **mapping, int nr_mapping, const char *var) > { > int i; > diff --git a/config.h b/config.h > index f0ed464004..612f43acd0 100644 > --- a/config.h > +++ b/config.h > @@ -139,6 +139,7 @@ enum config_scope { > }; > > enum config_scope current_config_scope(void); > +const char *config_scope_to_string(enum config_scope); > const char *current_config_origin_type(void); > const char *current_config_name(void); >