git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* builtin/config: --name-only doesn't imply --show-names in "git config get"
@ 2024-08-21  8:10 Yukai Chou
  2024-08-21 16:06 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Yukai Chou @ 2024-08-21  8:10 UTC (permalink / raw)
  To: git; +Cc: ps

The v2.46.0 doc of git-config(1) says

> --name-only
> Output only the names of config variables for `list` or `get`.
https://git-scm.com/docs/git-config#Documentation/git-config.txt---name-only

But the behavior of --name-only is more like "disable non-name outputs
and leave the output state of names as-is". Thus using --name-only
alone, one gets totally empty lines (which might be weird); only using
--name-only and --show-names together, can one get output of just
names.

# get empty line(s)
git config get --all --name-only remote.origin.fetch
# get lines of name(s)
git config get --all --show-names --name-only remote.origin.fetch

Either the doc or the behavior of --name-only needs some adjustment.

Yukai Chou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: builtin/config: --name-only doesn't imply --show-names in "git config get"
  2024-08-21  8:10 builtin/config: --name-only doesn't imply --show-names in "git config get" Yukai Chou
@ 2024-08-21 16:06 ` Junio C Hamano
  2024-08-21 20:28   ` Yukai Chou
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2024-08-21 16:06 UTC (permalink / raw)
  To: Yukai Chou; +Cc: git, ps

Yukai Chou <muzimuzhi@gmail.com> writes:

> The v2.46.0 doc of git-config(1) says
>
>> --name-only
>> Output only the names of config variables for `list` or `get`.
> https://git-scm.com/docs/git-config#Documentation/git-config.txt---name-only
>
> But the behavior of --name-only is more like "disable non-name outputs
> and leave the output state of names as-is". Thus using --name-only
> alone, one gets totally empty lines (which might be weird); only using
> --name-only and --show-names together, can one get output of just
> names.
>
> # get empty line(s)
> git config get --all --name-only remote.origin.fetch
> # get lines of name(s)
> git config get --all --show-names --name-only remote.origin.fetch
>
> Either the doc or the behavior of --name-only needs some adjustment.

This argues for making "all" imply we need to show the name of the
configuration variable, and introducing an option "--hide-name" to
omit the name.  That way, you'd need to give clearly contradicting
"--hide-name" and "--name-only" together to get a nonsense output.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: builtin/config: --name-only doesn't imply --show-names in "git config get"
  2024-08-21 16:06 ` Junio C Hamano
@ 2024-08-21 20:28   ` Yukai Chou
  2024-08-21 20:59     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Yukai Chou @ 2024-08-21 20:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, ps

Junio C Hamano <gitster@pobox.com> 于2024年8月22日周四 00:07写道:
>
> Yukai Chou <muzimuzhi@gmail.com> writes:
>
> > # get empty line(s)
> > git config get --all --name-only remote.origin.fetch
> > # get lines of name(s)
> > git config get --all --show-names --name-only remote.origin.fetch
> >
> > Either the doc or the behavior of --name-only needs some adjustment.
>
> This argues for making "all" imply we need to show the name of the
> configuration variable,

Sorry can you elaborate on what that "all" meant? A new option "--show-all"?

> and introducing an option "--hide-name" to
> omit the name.  That way, you'd need to give clearly contradicting
> "--hide-name" and "--name-only" together to get a nonsense output.

I have a feeling that finally a collection of options shared by "git
config list" and "git config get" will be introduced to fully control
what they output, and even make the form of output given by one of
"git config list" and "git config get" look exactly like the other.

An ideal design:

--show-all
--[no-]show-scope
--[no-]show-origin
--[no-]show-name
--[no-]show-value
--hide-all
--separator=<sep> # fuzzy name?

Initial options
- git config list: --hide-all --show-name --show-value --separator="="
- git config get: --hide-all --show-value --separator=" "

The drawback is, quite some combinations of such options are nonsense.

Yukai

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: builtin/config: --name-only doesn't imply --show-names in "git config get"
  2024-08-21 20:28   ` Yukai Chou
@ 2024-08-21 20:59     ` Junio C Hamano
  2024-08-22  5:57       ` Patrick Steinhardt
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2024-08-21 20:59 UTC (permalink / raw)
  To: Yukai Chou; +Cc: git, ps

Yukai Chou <muzimuzhi@gmail.com> writes:

> Junio C Hamano <gitster@pobox.com> 于2024年8月22日周四 00:07写道:
>>
>> Yukai Chou <muzimuzhi@gmail.com> writes:
>>
>> > # get empty line(s)
>> > git config get --all --name-only remote.origin.fetch
>> > # get lines of name(s)
>> > git config get --all --show-names --name-only remote.origin.fetch
>> >
>> > Either the doc or the behavior of --name-only needs some adjustment.
>>
>> This argues for making "all" imply we need to show the name of the
>> configuration variable,
>
> Sorry can you elaborate on what that "all" meant? A new option "--show-all"?

Sorry, but "--all" is probably a red herring.

What I wanted to say was that we can 

 (1) get rid of "--show-name",

 (2) have the combination of options that can emit values for more
    than one key to automatically show both name and value, and

 (3) add "--hide-name" so that such command can still show only the
     value.

where I mixed up (2) and "all".  In fact, "--all" is not something
that gives values for more than one key (it is things like regexp
and urlmatch).

For example:

 $ git config --get-regexp 'sendemail\..*'

would show values for more than one variable, and depending on the 
variable, it may show the values for one variable more than once.
According to the documentation, this was replaced with

    --get-regexp <name-regexp>::
            Replaced by `git config get --all --show-names --regexp <name-regexp>`.

but it could have been

    git config get --all --regexp <name-regexp>

as it is clear --regexp could give results for more than one key.

This points at a bug in the documentation, by the way.  "git config --get-all"
is described like so:

    --get-all <name> [<value-pattern>]::
            Replaced by `git config get [--value=<pattern>] --all --show-names <name>`.

but this gives values for only one key, and the command does not
show key names.  It is replaced by

	git config get [--value=<pattern>] --all <name>

without "--show-names".


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: builtin/config: --name-only doesn't imply --show-names in "git config get"
  2024-08-21 20:59     ` Junio C Hamano
@ 2024-08-22  5:57       ` Patrick Steinhardt
  2024-08-22 14:54         ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick Steinhardt @ 2024-08-22  5:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Yukai Chou, git

On Wed, Aug 21, 2024 at 01:59:43PM -0700, Junio C Hamano wrote:
> Yukai Chou <muzimuzhi@gmail.com> writes:
> 
> > Junio C Hamano <gitster@pobox.com> 于2024年8月22日周四 00:07写道:
> >>
> >> Yukai Chou <muzimuzhi@gmail.com> writes:
> >>
> >> > # get empty line(s)
> >> > git config get --all --name-only remote.origin.fetch
> >> > # get lines of name(s)
> >> > git config get --all --show-names --name-only remote.origin.fetch
> >> >
> >> > Either the doc or the behavior of --name-only needs some adjustment.
> >>
> >> This argues for making "all" imply we need to show the name of the
> >> configuration variable,
> >
> > Sorry can you elaborate on what that "all" meant? A new option "--show-all"?
> 
> Sorry, but "--all" is probably a red herring.
> 
> What I wanted to say was that we can 
> 
>  (1) get rid of "--show-name",
> 
>  (2) have the combination of options that can emit values for more
>     than one key to automatically show both name and value, and
> 
>  (3) add "--hide-name" so that such command can still show only the
>      value.
> 
> where I mixed up (2) and "all".  In fact, "--all" is not something
> that gives values for more than one key (it is things like regexp
> and urlmatch).

I wouldn't get rid of `--show-name`, as it also implicitly brings along
`--no-show-name`, basically checking the box for (3).

In any case, I agree that it probably makes sense to do (2). Unless I'm
mistaken, the only case we need to care about is `--regexp`, because
without all the emitted names would be the same anyway.

Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: builtin/config: --name-only doesn't imply --show-names in "git config get"
  2024-08-22  5:57       ` Patrick Steinhardt
@ 2024-08-22 14:54         ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2024-08-22 14:54 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: Yukai Chou, git

Patrick Steinhardt <ps@pks.im> writes:

> In any case, I agree that it probably makes sense to do (2). Unless I'm
> mistaken, the only case we need to care about is `--regexp`, because
> without all the emitted names would be the same anyway.

OK.  And we need to fix the "config --get-all" description, which
does not need --show-names there, I think.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-22 14:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21  8:10 builtin/config: --name-only doesn't imply --show-names in "git config get" Yukai Chou
2024-08-21 16:06 ` Junio C Hamano
2024-08-21 20:28   ` Yukai Chou
2024-08-21 20:59     ` Junio C Hamano
2024-08-22  5:57       ` Patrick Steinhardt
2024-08-22 14:54         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).