Re: [PATCH 1.5/2] config: add options to list only variable names
From: Christian Couder <hidden>
Date: 2016-06-15 23:05:02
On Wed, May 27, 2015 at 10:11 PM, SZEDER Gábor [off-list ref] wrote:
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.