summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'config.c')
-rw-r--r--config.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/config.c b/config.c
index 2bdff4457b..b5e8ab13b3 100644
--- a/config.c
+++ b/config.c
@@ -2729,9 +2729,9 @@ void git_config_set(const char *key, const char *value)
* 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
* (only add a new one)
- * if multi_replace==0, nothing, or only one matching key/value is replaced,
- * else all matching key/values (regardless how many) are removed,
- * before the new pair is written.
+ * if flags contains the CONFIG_FLAGS_MULTI_REPLACE flag, all matching
+ * key/values are removed before a single new pair is written. If the
+ * flag is not present, then replace only the first match.
*
* Returns 0 on success.
*
@@ -2752,7 +2752,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,
- int multi_replace)
+ unsigned flags)
{
int fd = -1, in_fd = -1;
int ret;
@@ -2769,7 +2769,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
if (ret)
goto out_free;
- store.multi_replace = multi_replace;
+ store.multi_replace = (flags & CONFIG_FLAGS_MULTI_REPLACE) != 0;
if (!config_filename)
config_filename = filename_buf = git_pathdup("config");
@@ -2858,7 +2858,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
/* if nothing to unset, or too many matches, error out */
if ((store.seen_nr == 0 && value == NULL) ||
- (store.seen_nr > 1 && multi_replace == 0)) {
+ (store.seen_nr > 1 && !store.multi_replace)) {
ret = CONFIG_NOTHING_SET;
goto out_free;
}
@@ -2997,10 +2997,10 @@ write_err_out:
void git_config_set_multivar_in_file(const char *config_filename,
const char *key, const char *value,
- const char *value_regex, int multi_replace)
+ const char *value_regex, unsigned flags)
{
if (!git_config_set_multivar_in_file_gently(config_filename, key, value,
- value_regex, multi_replace))
+ value_regex, flags))
return;
if (value)
die(_("could not set '%s' to '%s'"), key, value);
@@ -3009,17 +3009,17 @@ 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, int multi_replace)
+ const char *value_regex, unsigned flags)
{
return git_config_set_multivar_in_file_gently(NULL, key, value, value_regex,
- multi_replace);
+ flags);
}
void git_config_set_multivar(const char *key, const char *value,
- const char *value_regex, int multi_replace)
+ const char *value_regex, unsigned flags)
{
git_config_set_multivar_in_file(NULL, key, value, value_regex,
- multi_replace);
+ flags);
}
static int section_name_match (const char *buf, const char *name)