git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] config: add string mapping for enum config_scope

From
Matt Rogers <mattr94@gmail.com>
Date
Dec 11, 2019, 23:52 UTC
Message-ID
<CAOjrSZsrNjzCojmA6kgSdhT9=G84twzv3Ced4VfNZD1SC2jb7Q@mail.gmail.com>
In-Reply-To
<20191211233820.185153-1-emilyshaffer@google.com>
On Wed, Dec 11, 2019 at 6:38 PM Emily Shaffer <emilyshaffer@google.com> wrote:
Show 67 quoted lines
>
> 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.
>
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> ---
>
> Since v1, the only change is removing locale markers around the strings
> returned from the helper.
>
> As mentioned in lore.kernel.org/git/20191211232540.GE8464@google.com I'm
> still not sure whether it's better to return "local" for
> CONFIG_SCOPE_REPO. Since that's the scope returned for both local and
> worktree (.git/config, .git/config.worktree) configs, I'm happy to leave
> it the way it is to indicate "one of the configs in the repo".
>
>  - Emily
>
>  config.c | 17 +++++++++++++++++
>  config.h |  1 +
>  2 files changed, 18 insertions(+)
>
> diff --git a/config.c b/config.c
> index e7052b3977..baab4a916e 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 91fd4c5e96..c8bf296dcc 100644
> --- a/config.h
> +++ b/config.h
> @@ -303,6 +303,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);
>
> --
> 2.24.0.525.g8f36a354ae-goog
>

Okay Good to know, I'm using gmail right now, so the default is to start at the top

I wouldn't really consider it a bug so much as just something that hasn't been an issue before. The way config.c is set up kind of makes it hard to pass in the information that it uses the --local option, so that may need to be refactored, since it just passes in the appropriate file based on the --local, etc. flags to builtin\config.c which has never really needed that information before now. Anyways, I don't think it needs to be addressed right now, and I'm working on something that would address it anyways... I just need to find some more time to work on it.

-- 
Matthew Rogers
Previous: Emily ShafferNext: Jeff King
Message 2 of 7 in “config: add string mapping for enum config_scope”
  1. config: add string mapping for enum config_scopeEmily Shaffer, Dec 11, 2019
  2. Matt RogersDec 11, 2019
  3. Jeff KingDec 12, 2019
  4. mattr94@gmail.comDec 12, 2019
  5. Jeff KingDec 12, 2019
  6. Emily ShafferDec 12, 2019
  7. Jeff KingDec 12, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.