diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2020-11-25 22:12:54 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-11-25 22:43:48 (GMT) |
commit | c90702a1f6f7473a959994a2dff0f0dd450b8029 (patch) | |
tree | 5a325cc4e319cd8e4a8a1b425abb48eea1c2652e /builtin/config.c | |
parent | fda43942d7b78d2c529a40e5e38fc34034d929cb (diff) | |
download | git-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 'builtin/config.c')
-rw-r--r-- | builtin/config.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/builtin/config.c b/builtin/config.c index f1b73ac..21892a7 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -633,6 +633,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) { int nongit = !startup_info->have_repository; char *value; + int flags = 0; given_config_source.file = xstrdup_or_null(getenv(CONFIG_ENVIRONMENT)); @@ -800,6 +801,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) error(_("--fixed-value only applies with 'value-pattern'")); usage_builtin_config(); } + + flags |= CONFIG_FLAGS_FIXED_VALUE; } if (actions & PAGING_ACTIONS) @@ -863,7 +866,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) value = normalize_value(argv[0], argv[1]); UNLEAK(value); return git_config_set_multivar_in_file_gently(given_config_source.file, - argv[0], value, argv[2], 0); + argv[0], value, argv[2], + flags); } else if (actions == ACTION_ADD) { check_write(); @@ -872,7 +876,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) UNLEAK(value); return git_config_set_multivar_in_file_gently(given_config_source.file, argv[0], value, - CONFIG_REGEX_NONE, 0); + CONFIG_REGEX_NONE, + flags); } else if (actions == ACTION_REPLACE_ALL) { check_write(); @@ -881,7 +886,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) UNLEAK(value); return git_config_set_multivar_in_file_gently(given_config_source.file, argv[0], value, argv[2], - CONFIG_FLAGS_MULTI_REPLACE); + flags | CONFIG_FLAGS_MULTI_REPLACE); } else if (actions == ACTION_GET) { check_argc(argc, 1, 2); @@ -908,7 +913,8 @@ int cmd_config(int argc, const char **argv, const char *prefix) check_argc(argc, 1, 2); if (argc == 2) return git_config_set_multivar_in_file_gently(given_config_source.file, - argv[0], NULL, argv[1], 0); + argv[0], NULL, argv[1], + flags); else return git_config_set_in_file_gently(given_config_source.file, argv[0], NULL); @@ -918,7 +924,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) check_argc(argc, 1, 2); return git_config_set_multivar_in_file_gently(given_config_source.file, argv[0], NULL, argv[1], - CONFIG_FLAGS_MULTI_REPLACE); + flags | CONFIG_FLAGS_MULTI_REPLACE); } else if (actions == ACTION_RENAME_SECTION) { int ret; |