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

Re: [BUG?] "git config --replace-all key value value_regex" ignores value_regex?

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2020, 18:54 UTC
Message-ID
<xmqqo8ju1ooc.fsf@gitster.c.googlers.com>
In-Reply-To
<466ee1d8-efaa-fc91-f3d9-230672289ffb@gmail.com>
Derrick Stolee <stolee@gmail.com> writes:
Show 22 quoted lines
> --replace-all::
> 	Default behavior is to replace at most one line. This replaces
> 	all lines matching the key (and optionally the value_regex).
>
> However, this test fails:
>
> test_expect_success '--replace-all and value_regex' '
> 	q_to_tab >.git/config <<-\EOF &&
> 	[abc]
> 	Qkey = one
> 	Qkey = two
> 	Qkey = three
> 	EOF
> 	q_to_tab >expect <<-\EOF &&
> 	[abc]
> 	Qkey = four
> 	Qkey = two
> 	Qkey = three
> 	EOF
> 	git config --replace-all abc.key four "o*" &&
> 	test_cmp expect .git/config
> '

I do not know or try to guess the original intention (I thought this is Dscho's thing, no?), but if there are one/two/three and I were asked to replace all of those that have zero or more 'o' in it with 'four' I would expect that

 (1) all three be removed, because they all have zero or more 'o',
     and then
 (2) one instance of 'four' be added,
resulting in a single 'four' left.

If the value_regex were "o+" (since it takes ERE) to mean one or more, then my expectation would be

 (1) one and two be removed, because 'three' does not match, and
     then
 (2) one instance of 'four' be added,
resulting in two items, 'three' and 'four'.

An alternative interpretation would be that each of the removed entries is replaced with a new one, resulting in three entries (i.e. with "o*", it would leave three identical entries 'four', with "o+", it would leave 'four', 'four' and 'three'), but that may be less useful in practice.

Previous: Derrick StoleeNext: Derrick Stolee
Message 2 of 4 in “[BUG?] "git config --replace-all key value value_regex" ignores value_regex?”
  1. Derrick StoleeNov 18, 2020
  2. Junio C HamanoNov 18, 2020
  3. Derrick StoleeNov 18, 2020
  4. Junio C HamanoNov 18, 2020

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.