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

Re: [PATCH 2/6] config: add string mapping for enum config_scope

From
Philip Oakley <philipoakley@iee.email>
Date
Dec 10, 2019, 11:16 UTC
Message-ID
<e0bcedec-dd1c-9cb7-1b0f-a8fda0bbf610@iee.email>
In-Reply-To
<20191210023335.49987-3-emilyshaffer@google.com>
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
Show 47 quoted lines
>
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> ---
>   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);
>   
Previous: Emily ShafferNext: Philip Oakley
Message 6 of 19 in “configuration-based hook management”
  1. 0/6 configuration-based hook managementEmily Shaffer, Dec 10, 2019
  2. 1/6 hook: scaffolding for git-hook subcommandEmily Shaffer, Dec 10, 2019
  3. Bert WesargDec 12, 2019
  4. SZEDER GáborDec 12, 2019
  5. 2/6 config: add string mapping for enum config_scopeEmily Shaffer, Dec 10, 2019
  6. Philip OakleyDec 10, 2019
  7. Philip OakleyDec 10, 2019
  8. 3/6 hook: add --list modeEmily Shaffer, Dec 10, 2019
  9. Bert WesargDec 12, 2019
  10. SZEDER GáborDec 12, 2019
  11. 4/6 hook: support reordering of hook listEmily Shaffer, Dec 10, 2019
  12. Junio C HamanoDec 11, 2019
  13. 5/6 hook: remove prior hook with '---'Emily Shaffer, Dec 10, 2019
  14. 6/6 hook: teach --porcelain modeEmily Shaffer, Dec 10, 2019
  15. Junio C HamanoDec 11, 2019
  16. Emily ShafferDec 11, 2019
  17. Junio C HamanoDec 11, 2019
  18. Emily ShafferDec 11, 2019
  19. Junio C HamanoDec 11, 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.