list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <>
To: Junio C Hamano <>
Cc: Git List <>,
	Johannes Schindelin <>,
	Jeff King <>,
	Emily Shaffer <>
Subject: Re: [BUG?] "git config --replace-all key value value_regex" ignores value_regex?
Date: Wed, 18 Nov 2020 14:42:37 -0500	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 11/18/2020 1:54 PM, Junio C Hamano wrote:
> Derrick Stolee <> writes:
>> --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.

Thank you. Naturally, PEBKAC and my lack of understanding the
regex I was using in my own test. Clearly this is behaving
correctly. Modifying as suggested shows this works properly.



  reply	other threads:[~2020-11-18 19:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 18:07 Derrick Stolee
2020-11-18 18:54 ` Junio C Hamano
2020-11-18 19:42   ` Derrick Stolee [this message]
2020-11-18 20:28     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \
    --subject='Re: [BUG?] "git config --replace-all key value value_regex" ignores value_regex?' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

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 read-only IMAP folder(s) and NNTP newsgroup(s).