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

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

From
Matt Rogers <mattr94@gmail.com>
Date
Dec 11, 2019, 23:14 UTC
Message-ID
<CAOjrSZuOOG=MbetP0RWYwLB+Zv5EZAHqkvkm0+WkBmSqxXiVTQ@mail.gmail.com>
In-Reply-To
<20191211231146.GC8464@google.com>

Another thing I also want to point out is that outside of this function... when git config is called with the --local, etc. the config scope is not actually CONFIG_SCOPE_LOCAL but CONFIG_SCOPE_UNKNOWN. This is because the config machinery pretty much equates --local and --file=./.git/config as pretty much equivalent (assuming ./.git is the actual repo directory location). So just something to keep in mind.

On Wed, Dec 11, 2019 at 6:11 PM Emily Shaffer <emilyshaffer@google.com> wrote:
Show 45 quoted lines
>
> On Wed, Dec 11, 2019 at 02:19:57PM -0800, Junio C Hamano wrote:
> > Emily Shaffer <emilyshaffer@google.com> writes:
> >
> > > 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>
> > > ---
> > > Note: This commit has been cherry-picked out of the "configuration-based
> > > hook management" topic, at
> > > lore.kernel.org/git/20191210023335.49987-1-emilyshaffer@google.com
> > >
> > > It turned out that I wanted to use it for git-bugreport as well - to
> > > explain the origin of the configs we are printing in the bugreport,
> > > without directly exposing the user's home directory path.
> > >
> > > This seems to have similar work to https://github.com/gitgitgadget/git/pull/478
> > > which I believe hasn't been mailed yet; but that change is targeted
> > > towards the builtin config command, rather than the config library.
> > > Since I wanted to use the library, I'm sending on my own now. Maybe
> > > this commit will be useful to that change's author.
> >
> > One thing I wondered about this in the original version was if the
> > returned value should be localized.  In the context of the original,
> > the --porcelain mode refused to give this information in its output,
> > so it was OK to always localize the returned value to satisify the
> > other caller who wanted end-user-facing output.
> >
> > But as a more general helper, I am not sure if this is the most
> > useful way to implement it.  Shouldn't the function rather return
> > the machine-readable tokens and allow callers to localize it as
> > needed with its own _() around the returned value?  I dunno.
> >
> Hm. I think that's a good point, and allows this helper to be used for
> something silly like putting together a sample invocation to 'git
> config' if desired. It's meant to mirror the scope given to 'git config'
> - which makes me think that no, it shouldn't be localized, since the
> argument isn't localized either.
>
> Ok, I'll take the locale marker off.
>
>  - Emily
-- 
Matthew Rogers
Previous: Emily ShafferNext: Emily Shaffer
Message 4 of 6 in “config: add string mapping for enum config_scope”
  1. config: add string mapping for enum config_scopeEmily Shaffer, Dec 11, 2019
  2. Junio C HamanoDec 11, 2019
  3. Emily ShafferDec 11, 2019
  4. Matt RogersDec 11, 2019
  5. Emily ShafferDec 11, 2019
  6. Emily ShafferDec 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.