git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
	Emily Shaffer <emilyshaffer@google.com>
Subject: [BUG?] "git config --replace-all key value value_regex" ignores value_regex?
Date: Wed, 18 Nov 2020 13:07:29 -0500	[thread overview]
Message-ID: <466ee1d8-efaa-fc91-f3d9-230672289ffb@gmail.com> (raw)

As discussed [1], I am working on relaxing the "regex" part of the
value_regex parameter in the "git config" command.

[1] https://lore.kernel.org/git/xmqqlfez6alb.fsf@gitster.c.googlers.com/

As I am working to solidify how this command works, I'm adding tests
for all of the compatible options that could use a "--literal-value"
modifier. One that seemed helpful to use was "--replace-all". The
docs have this line in the SYNOPSIS:

'git config' [<file-option>] [--type=<type>] [--literal-value] --replace-all name value [value_regex]

and this in the OPTIONS:

--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
'

The end result is that _all_ existing values are removed in
favor of one final result of abc.key=four.

Is this the intended behavior? It seems like value_regex is completely
ignored instead of actually performing a function here. The only
mailing list reference I can find include a doc update [2] and the original
implementation from 2005 [3].

[2] https://lore.kernel.org/git/alpine.LFD.2.21.1805300733440.10096@localhost.localdomain/
[3] https://lore.kernel.org/git/Pine.LNX.4.63.0511200650130.12832@wbgn013.biozentrum.uni-wuerzburg.de/

If it is _not_ the intended behavior, then would a fix to make my test
pass be appropriate? If anyone is currently specifying a value_regex
to this command, then the behavior would change in surprising ways.
However, it seems that they would get the same behavior without using
value_regex.

Thanks,
-Stolee

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18 18:07 Derrick Stolee [this message]
2020-11-18 18:54 ` Junio C Hamano
2020-11-18 19:42   ` Derrick Stolee
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=466ee1d8-efaa-fc91-f3d9-230672289ffb@gmail.com \
    --to=stolee@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

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).