From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Jonathan Nieder" <jrnieder@gmail.com>,
"Emily Shaffer" <emilyshaffer@google.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Jeff King" <peff@peff.net>,
"brian m. carlson" <sandals@crustytoothpaste.net>,
"Martin Ågren" <martin.agren@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Derrick Stolee" <stolee@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Derrick Stolee" <derrickstolee@github.com>,
"Derrick Stolee" <dstolee@microsoft.com>
Subject: [PATCH v3 2/8] config: replace 'value_regex' with 'value_pattern'
Date: Wed, 25 Nov 2020 22:12:50 +0000 [thread overview]
Message-ID: <f135b001ad911c079b0754c61e2179277ce37e0f.1606342377.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.796.v3.git.1606342376.gitgitgadget@gmail.com>
From: Derrick Stolee <dstolee@microsoft.com>
The 'value_regex' argument in the 'git config' builtin is poorly named,
especially related to an upcoming change that allows exact string
matches instead of ERE pattern matches.
Perform a mostly mechanical change of every instance of 'value_regex' to
'value_pattern' in the codebase. This is only critical for documentation
and error messages, but it is best to be consistent inside the codebase,
too.
For documentation, use 'value-pattern' which is better punctuation. This
affects Documentation/git-config.txt and the usage in builtin/config.c,
which was already mixed between 'value_regex' and 'value-regex'.
I gave some thought to leaving the value_regex variables inside config.c
that are regex_t pointers. However, it is probably best to keep the name
consistent with the rest of the variables.
This does not update the translations inside the po/ directory, as that
creates conflicts with ongoing work. The input strings should
automatically update through automation, and a few of the output strings
currently use "[value_regex]" directly.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
Documentation/git-config.txt | 20 ++++++-------
builtin/config.c | 12 ++++----
config.c | 54 ++++++++++++++++++------------------
config.h | 2 +-
4 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 7573160f21..0be5499952 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -9,15 +9,15 @@ git-config - Get and set repository or global options
SYNOPSIS
--------
[verse]
-'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] name [value [value_regex]]
+'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] name [value [value-pattern]]
'git config' [<file-option>] [--type=<type>] --add name value
-'git config' [<file-option>] [--type=<type>] --replace-all name value [value_regex]
-'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] --get name [value_regex]
-'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] --get-all name [value_regex]
-'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--name-only] --get-regexp name_regex [value_regex]
+'git config' [<file-option>] [--type=<type>] --replace-all name value [value-pattern]
+'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] --get name [value-pattern]
+'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] --get-all name [value-pattern]
+'git config' [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--name-only] --get-regexp name_regex [value-pattern]
'git config' [<file-option>] [--type=<type>] [-z|--null] --get-urlmatch name URL
-'git config' [<file-option>] --unset name [value_regex]
-'git config' [<file-option>] --unset-all name [value_regex]
+'git config' [<file-option>] --unset name [value-pattern]
+'git config' [<file-option>] --unset-all name [value-pattern]
'git config' [<file-option>] --rename-section old_name new_name
'git config' [<file-option>] --remove-section name
'git config' [<file-option>] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list
@@ -33,7 +33,7 @@ escaped.
Multiple lines can be added to an option by using the `--add` option.
If you want to update or unset an option which can occur on multiple
-lines, a POSIX regexp `value_regex` needs to be given. Only the
+lines, a POSIX regexp `value-pattern` needs to be given. Only the
existing values that match the regexp are updated or unset. If
you want to handle the lines that do *not* match the regex, just
prepend a single exclamation mark in front (see also <<EXAMPLES>>).
@@ -73,11 +73,11 @@ OPTIONS
--replace-all::
Default behavior is to replace at most one line. This replaces
- all lines matching the key (and optionally the value_regex).
+ all lines matching the key (and optionally the `value-pattern`).
--add::
Adds a new line to the option without altering any existing
- values. This is the same as providing '^$' as the value_regex
+ values. This is the same as providing '^$' as the `value-pattern`
in `--replace-all`.
--get::
diff --git a/builtin/config.c b/builtin/config.c
index e7c7f3d455..9d97091561 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -130,14 +130,14 @@ static struct option builtin_config_options[] = {
OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")),
OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object")),
OPT_GROUP(N_("Action")),
- OPT_BIT(0, "get", &actions, N_("get value: name [value-regex]"), ACTION_GET),
- OPT_BIT(0, "get-all", &actions, N_("get all values: key [value-regex]"), ACTION_GET_ALL),
- OPT_BIT(0, "get-regexp", &actions, N_("get values for regexp: name-regex [value-regex]"), ACTION_GET_REGEXP),
+ OPT_BIT(0, "get", &actions, N_("get value: name [value-pattern]"), ACTION_GET),
+ OPT_BIT(0, "get-all", &actions, N_("get all values: key [value-pattern]"), ACTION_GET_ALL),
+ OPT_BIT(0, "get-regexp", &actions, N_("get values for regexp: name-regex [value-pattern]"), ACTION_GET_REGEXP),
OPT_BIT(0, "get-urlmatch", &actions, N_("get value specific for the URL: section[.var] URL"), ACTION_GET_URLMATCH),
- OPT_BIT(0, "replace-all", &actions, N_("replace all matching variables: name value [value_regex]"), ACTION_REPLACE_ALL),
+ OPT_BIT(0, "replace-all", &actions, N_("replace all matching variables: name value [value-pattern]"), ACTION_REPLACE_ALL),
OPT_BIT(0, "add", &actions, N_("add a new variable: name value"), ACTION_ADD),
- OPT_BIT(0, "unset", &actions, N_("remove a variable: name [value-regex]"), ACTION_UNSET),
- OPT_BIT(0, "unset-all", &actions, N_("remove all matches: name [value-regex]"), ACTION_UNSET_ALL),
+ OPT_BIT(0, "unset", &actions, N_("remove a variable: name [value-pattern]"), ACTION_UNSET),
+ OPT_BIT(0, "unset-all", &actions, N_("remove all matches: name [value-pattern]"), ACTION_UNSET_ALL),
OPT_BIT(0, "rename-section", &actions, N_("rename section: old-name new-name"), ACTION_RENAME_SECTION),
OPT_BIT(0, "remove-section", &actions, N_("remove a section: name"), ACTION_REMOVE_SECTION),
OPT_BIT('l', "list", &actions, N_("list all"), ACTION_LIST),
diff --git a/config.c b/config.c
index f34a11d94b..ac6aace166 100644
--- a/config.c
+++ b/config.c
@@ -2402,7 +2402,7 @@ struct config_store_data {
size_t baselen;
char *key;
int do_not_match;
- regex_t *value_regex;
+ regex_t *value_pattern;
int multi_replace;
struct {
size_t begin, end;
@@ -2416,10 +2416,10 @@ struct config_store_data {
static void config_store_data_clear(struct config_store_data *store)
{
free(store->key);
- if (store->value_regex != NULL &&
- store->value_regex != CONFIG_REGEX_NONE) {
- regfree(store->value_regex);
- free(store->value_regex);
+ if (store->value_pattern != NULL &&
+ store->value_pattern != CONFIG_REGEX_NONE) {
+ regfree(store->value_pattern);
+ free(store->value_pattern);
}
free(store->parsed);
free(store->seen);
@@ -2431,13 +2431,13 @@ static int matches(const char *key, const char *value,
{
if (strcmp(key, store->key))
return 0; /* not ours */
- if (!store->value_regex)
+ if (!store->value_pattern)
return 1; /* always matches */
- if (store->value_regex == CONFIG_REGEX_NONE)
+ if (store->value_pattern == CONFIG_REGEX_NONE)
return 0; /* never matches */
return store->do_not_match ^
- (value && !regexec(store->value_regex, value, 0, NULL, 0));
+ (value && !regexec(store->value_pattern, value, 0, NULL, 0));
}
static int store_aux_event(enum config_event_t type,
@@ -2713,8 +2713,8 @@ void git_config_set(const char *key, const char *value)
/*
* If value==NULL, unset in (remove from) config,
- * if value_regex!=NULL, disregard key/value pairs where value does not match.
- * if value_regex==CONFIG_REGEX_NONE, do not match any existing values
+ * if value_pattern!=NULL, disregard key/value pairs where value does not match.
+ * if value_pattern==CONFIG_REGEX_NONE, do not match any existing values
* (only add a new one)
* if flags contains the CONFIG_FLAGS_MULTI_REPLACE flag, all matching
* key/values are removed before a single new pair is written. If the
@@ -2738,7 +2738,7 @@ void git_config_set(const char *key, const char *value)
*/
int git_config_set_multivar_in_file_gently(const char *config_filename,
const char *key, const char *value,
- const char *value_regex,
+ const char *value_pattern,
unsigned flags)
{
int fd = -1, in_fd = -1;
@@ -2799,22 +2799,22 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
int i, new_line = 0;
struct config_options opts;
- if (value_regex == NULL)
- store.value_regex = NULL;
- else if (value_regex == CONFIG_REGEX_NONE)
- store.value_regex = CONFIG_REGEX_NONE;
+ if (value_pattern == NULL)
+ store.value_pattern = NULL;
+ else if (value_pattern == CONFIG_REGEX_NONE)
+ store.value_pattern = CONFIG_REGEX_NONE;
else {
- if (value_regex[0] == '!') {
+ if (value_pattern[0] == '!') {
store.do_not_match = 1;
- value_regex++;
+ value_pattern++;
} else
store.do_not_match = 0;
- store.value_regex = (regex_t*)xmalloc(sizeof(regex_t));
- if (regcomp(store.value_regex, value_regex,
+ store.value_pattern = (regex_t*)xmalloc(sizeof(regex_t));
+ if (regcomp(store.value_pattern, value_pattern,
REG_EXTENDED)) {
- error(_("invalid pattern: %s"), value_regex);
- FREE_AND_NULL(store.value_regex);
+ error(_("invalid pattern: %s"), value_pattern);
+ FREE_AND_NULL(store.value_pattern);
ret = CONFIG_INVALID_PATTERN;
goto out_free;
}
@@ -2984,10 +2984,10 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
void git_config_set_multivar_in_file(const char *config_filename,
const char *key, const char *value,
- const char *value_regex, unsigned flags)
+ const char *value_pattern, unsigned flags)
{
if (!git_config_set_multivar_in_file_gently(config_filename, key, value,
- value_regex, flags))
+ value_pattern, flags))
return;
if (value)
die(_("could not set '%s' to '%s'"), key, value);
@@ -2996,16 +2996,16 @@ void git_config_set_multivar_in_file(const char *config_filename,
}
int git_config_set_multivar_gently(const char *key, const char *value,
- const char *value_regex, unsigned flags)
+ const char *value_pattern, unsigned flags)
{
- return git_config_set_multivar_in_file_gently(NULL, key, value, value_regex,
+ return git_config_set_multivar_in_file_gently(NULL, key, value, value_pattern,
flags);
}
void git_config_set_multivar(const char *key, const char *value,
- const char *value_regex, unsigned flags)
+ const char *value_pattern, unsigned flags)
{
- git_config_set_multivar_in_file(NULL, key, value, value_regex,
+ git_config_set_multivar_in_file(NULL, key, value, value_pattern,
flags);
}
diff --git a/config.h b/config.h
index 58726c34d6..8ad1085b74 100644
--- a/config.h
+++ b/config.h
@@ -296,7 +296,7 @@ int git_config_set_multivar_in_file_gently(const char *, const char *, const cha
void git_config_set_multivar_in_file(const char *config_filename,
const char *key,
const char *value,
- const char *value_regex,
+ const char *value_pattern,
unsigned flags);
/**
--
gitgitgadget
next prev parent reply other threads:[~2020-11-25 22:30 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 15:52 [PATCH 0/7] config: add --literal-value option Derrick Stolee via GitGitGadget
2020-11-19 15:52 ` [PATCH 1/7] t1300: test "set all" mode with value_regex Derrick Stolee via GitGitGadget
2020-11-19 22:24 ` Junio C Hamano
2020-11-20 2:09 ` brian m. carlson
2020-11-20 2:33 ` Junio C Hamano
2020-11-20 18:39 ` Jeff King
2020-11-20 22:35 ` Junio C Hamano
2020-11-21 22:27 ` brian m. carlson
2020-11-22 3:31 ` Junio C Hamano
2020-11-24 2:38 ` Jeff King
2020-11-24 19:43 ` Junio C Hamano
2020-11-19 15:52 ` [PATCH 2/7] t1300: add test for --replace-all " Derrick Stolee via GitGitGadget
2020-11-19 15:52 ` [PATCH 3/7] config: convert multi_replace to flags Derrick Stolee via GitGitGadget
2020-11-19 22:32 ` Junio C Hamano
2020-11-19 15:52 ` [PATCH 4/7] config: add --literal-value option, un-implemented Derrick Stolee via GitGitGadget
2020-11-19 22:42 ` Junio C Hamano
2020-11-20 6:35 ` Martin Ågren
2020-11-19 15:52 ` [PATCH 5/7] config: plumb --literal-value into config API Derrick Stolee via GitGitGadget
2020-11-19 22:45 ` Junio C Hamano
2020-11-19 15:52 ` [PATCH 6/7] config: implement --literal-value with --get* Derrick Stolee via GitGitGadget
2020-11-19 15:52 ` [PATCH 7/7] maintenance: use 'git config --literal-value' Derrick Stolee via GitGitGadget
2020-11-19 23:17 ` Junio C Hamano
2020-11-20 13:19 ` [PATCH 0/7] config: add --literal-value option Ævar Arnfjörð Bjarmason
2020-11-20 13:23 ` Derrick Stolee
2020-11-20 18:30 ` Junio C Hamano
2020-11-20 18:51 ` Derrick Stolee
2020-11-20 21:52 ` Junio C Hamano
2020-11-24 12:35 ` Ævar Arnfjörð Bjarmason
2020-11-23 16:05 ` [PATCH v2 0/7] config: add --fixed-value option Derrick Stolee via GitGitGadget
2020-11-23 16:05 ` [PATCH v2 1/7] t1300: test "set all" mode with value_regex Derrick Stolee via GitGitGadget
2020-11-23 19:37 ` Emily Shaffer
2020-11-23 16:05 ` [PATCH v2 2/7] t1300: add test for --replace-all " Derrick Stolee via GitGitGadget
2020-11-23 19:40 ` Emily Shaffer
2020-11-23 16:05 ` [PATCH v2 3/7] config: convert multi_replace to flags Derrick Stolee via GitGitGadget
2020-11-23 21:43 ` Emily Shaffer
2020-11-23 16:05 ` [PATCH v2 4/7] config: add --fixed-value option, un-implemented Derrick Stolee via GitGitGadget
2020-11-23 19:37 ` Junio C Hamano
2020-11-23 21:51 ` Emily Shaffer
2020-11-23 22:41 ` Junio C Hamano
2020-11-25 14:08 ` Derrick Stolee
2020-11-25 17:22 ` Derrick Stolee
2020-11-25 17:28 ` Eric Sunshine
2020-11-25 19:30 ` Junio C Hamano
2020-11-25 19:29 ` Junio C Hamano
2020-11-23 16:05 ` [PATCH v2 5/7] config: plumb --fixed-value into config API Derrick Stolee via GitGitGadget
2020-11-23 22:21 ` Emily Shaffer
2020-11-24 0:52 ` Eric Sunshine
2020-11-25 15:41 ` Derrick Stolee
2020-11-25 17:55 ` Eric Sunshine
2020-11-23 16:05 ` [PATCH v2 6/7] config: implement --fixed-value with --get* Derrick Stolee via GitGitGadget
2020-11-23 19:53 ` Junio C Hamano
2020-11-23 22:43 ` Emily Shaffer
2020-11-23 16:05 ` [PATCH v2 7/7] maintenance: use 'git config --fixed-value' Derrick Stolee via GitGitGadget
2020-11-23 21:39 ` Junio C Hamano
2020-11-23 22:48 ` Emily Shaffer
2020-11-23 23:27 ` Junio C Hamano
2020-11-23 19:33 ` [PATCH v2 0/7] config: add --fixed-value option Junio C Hamano
2020-11-25 22:12 ` [PATCH v3 0/8] " Derrick Stolee via GitGitGadget
2020-11-25 22:12 ` [PATCH v3 1/8] config: convert multi_replace to flags Derrick Stolee via GitGitGadget
2020-11-25 22:12 ` Derrick Stolee via GitGitGadget [this message]
2020-11-25 22:50 ` [PATCH v3 2/8] config: replace 'value_regex' with 'value_pattern' Eric Sunshine
2020-11-25 22:12 ` [PATCH v3 3/8] t1300: test "set all" mode with value-pattern Derrick Stolee via GitGitGadget
2020-11-25 22:12 ` [PATCH v3 4/8] t1300: add test for --replace-all " Derrick Stolee via GitGitGadget
2020-11-25 22:12 ` [PATCH v3 5/8] config: add --fixed-value option, un-implemented Derrick Stolee via GitGitGadget
2020-11-25 23:04 ` Eric Sunshine
2020-11-25 22:12 ` [PATCH v3 6/8] config: plumb --fixed-value into config API Derrick Stolee via GitGitGadget
2020-11-25 22:12 ` [PATCH v3 7/8] config: implement --fixed-value with --get* Derrick Stolee via GitGitGadget
2020-11-25 22:12 ` [PATCH v3 8/8] maintenance: use 'git config --fixed-value' Derrick Stolee via GitGitGadget
2020-11-25 23:09 ` Junio C Hamano
2020-11-25 23:00 ` [PATCH v3 0/8] config: add --fixed-value option Junio C Hamano
2020-11-26 11:17 ` Derrick Stolee
2020-12-01 4:45 ` 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=f135b001ad911c079b0754c61e2179277ce37e0f.1606342377.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=derrickstolee@github.com \
--cc=dstolee@microsoft.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=martin.agren@gmail.com \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
--cc=stolee@gmail.com \
--cc=sunshine@sunshineco.com \
/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 public 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).