summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-11-25 22:12:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-25 22:43:48 (GMT)
commitc90702a1f6f7473a959994a2dff0f0dd450b8029 (patch)
tree5a325cc4e319cd8e4a8a1b425abb48eea1c2652e /config.c
parentfda43942d7b78d2c529a40e5e38fc34034d929cb (diff)
downloadgit-c90702a1f6f7473a959994a2dff0f0dd450b8029.zip
git-c90702a1f6f7473a959994a2dff0f0dd450b8029.tar.gz
git-c90702a1f6f7473a959994a2dff0f0dd450b8029.tar.bz2
config: plumb --fixed-value into config API
The git_config_set_multivar_in_file_gently() and related methods now take a 'flags' bitfield, so add a new bit representing the --fixed-value option from 'git config'. This alters the purpose of the value_pattern parameter to be an exact string match. This requires some initialization changes in git_config_set_multivar_in_file_gently() and a new strcmp() call in the matches() method. The new CONFIG_FLAGS_FIXED_VALUE flag is initialized in builtin/config.c based on the --fixed-value option, and that needs to be updated in several callers. This patch only affects some of the modes of 'git config', and the rest will be completed in the next change. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/config.c b/config.c
index 5b2f00f..3b2edc0 100644
--- a/config.c
+++ b/config.c
@@ -2415,6 +2415,7 @@ struct config_store_data {
size_t baselen;
char *key;
int do_not_match;
+ const char *fixed_value;
regex_t *value_pattern;
int multi_replace;
struct {
@@ -2444,6 +2445,8 @@ static int matches(const char *key, const char *value,
{
if (strcmp(key, store->key))
return 0; /* not ours */
+ if (store->fixed_value)
+ return !strcmp(store->fixed_value, value);
if (!store->value_pattern)
return 1; /* always matches */
if (store->value_pattern == CONFIG_REGEX_NONE)
@@ -2816,6 +2819,8 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
store.value_pattern = NULL;
else if (value_pattern == CONFIG_REGEX_NONE)
store.value_pattern = CONFIG_REGEX_NONE;
+ else if (flags & CONFIG_FLAGS_FIXED_VALUE)
+ store.fixed_value = value_pattern;
else {
if (value_pattern[0] == '!') {
store.do_not_match = 1;