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

Re: [PATCH 1.5/2] config: add options to list only variable names

From
Christian Couder <christian.couder@gmail.com>
Date
May 28, 2015, 12:06 UTC
Message-ID
<CAP8UFD32erihiEqkwaR6B09rEW7WJJ=Aq955KqErr3MdfQ3S_w@mail.gmail.com>
In-Reply-To
<1432757503-5787-1-git-send-email-szeder@ira.uka.de>
On Wed, May 27, 2015 at 10:11 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:
Show 30 quoted lines
> Recenty I created a multi-line branch description with '.' and '='
> characters on one of the lines, and noticed that fragments of that line
> show up when completing set variable names for 'git config', e.g.:
>
>   $ git config --get branch.b.description
>   Branch description to fool the completion script with a
>   second line containing dot . and equals = characters.
>   $ git config --unset <TAB>
>   ...
>   second line containing dot . and equals
>   ...
>
> The completion script runs 'git config --list' and processes its output to
> strip the values and keep only the variable names.  It does so by looking
> for lines containing '.' and '=' and outputting everything before the '=',
> which was fooled by my multi-line branch description.
>
> A similar issue exists with aliases and pretty format aliases with
> multi-line values, but in that case 'git config --get-regexp' is run and
> subsequent lines don't have to contain either '.' or '=' to fool the
> completion script.
>
> Though 'git config' can produce null-terminated output for newline-safe
> parsing, that's of no use in this case, becase we can't cope with nulls in
> the shell.
>
> Help the completion script by introducing the '--list-names' and
> '--get-names-regexp' options, the "names-only" equivalents of '--list' and
> '--get-regexp', so it doesn't have to separate variable names from their
> values anymore.

Why don't you just add a '--name-only' option that can be used only with '--list' and '--get-regexp'?

Like:
'git config' [<file-option>] [-z|--null] [--name-only] --get-regexp name_regex
and
'git config' [<file-option>] [-z|--null] [--name-only] -l | --list
?

It seems to me that it would reduce the number of options, and later if we want to pass a format we could have maybe:

'git config' [<file-option>] [-z|--null] [--name-only | --format=<format>] --get-regexp name_regex

and

'git config' [<file-option>] [-z|--null] [--name-only | --format=<format>] -l | --list

Thanks, Christian.

Previous: SZEDER GáborNext: Jeff King
Message 4 of 17 in “config: add options to list only variable names”
  1. 1/2 config: add options to list only variable namesSZEDER Gábor, May 27, 2015
  2. 2/2 completion: use new 'git config' options to reliably list variable namesSZEDER Gábor, May 27, 2015
  3. 5/2 config: add options to list only variable namesSZEDER Gábor, May 27, 2015
  4. Christian CouderMay 28, 2015
  5. Jeff KingMay 27, 2015
  6. Jeff KingMay 27, 2015
  7. Jeff KingMay 27, 2015
  8. SZEDER GáborMay 27, 2015
  9. Junio C HamanoMay 27, 2015
  10. 0/2 config: list only variable names for completionSZEDER Gábor, May 28, 2015
  11. 1/2 config: add options to list only variable namesSZEDER Gábor, May 28, 2015
  12. Junio C HamanoMay 28, 2015
  13. Junio C HamanoMay 28, 2015
  14. Christian CouderMay 29, 2015
  15. Jeff KingMay 29, 2015
  16. 2/2 completion: use new 'git config' options to reliably list variable namesSZEDER Gábor, May 28, 2015
  17. Jeff KingMay 28, 2015

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.