2415
size_t baselen;
2416
char *key;
2417
int do_not_match;
2418
- regex_t *value_regex;
2418
+ regex_t *value_pattern;
2419
int multi_replace;
2420
struct {
2421
size_t begin, end;
2429
static void config_store_data_clear(struct config_store_data *store)
2430
{
2431
free(store->key);
2432
- if (store->value_regex != NULL &&
2433
- store->value_regex != CONFIG_REGEX_NONE) {
2434
- regfree(store->value_regex);
2435
- free(store->value_regex);
2432
+ if (store->value_pattern != NULL &&
2433
+ store->value_pattern != CONFIG_REGEX_NONE) {
2434
+ regfree(store->value_pattern);
2435
+ free(store->value_pattern);
2436
}
2437
free(store->parsed);
2438
free(store->seen);
2444
{
2445
if (strcmp(key, store->key))
2446
return 0; /* not ours */
2447
- if (!store->value_regex)
2447
+ if (!store->value_pattern)
2448
return 1; /* always matches */
2449
- if (store->value_regex == CONFIG_REGEX_NONE)
2449
+ if (store->value_pattern == CONFIG_REGEX_NONE)
2450
return 0; /* never matches */
2451
2452
return store->do_not_match ^
2453
- (value && !regexec(store->value_regex, value, 0, NULL, 0));
2453
+ (value && !regexec(store->value_pattern, value, 0, NULL, 0));
2454
}
2455
2456
static int store_aux_event(enum config_event_t type,
2726
2727
/*
2728
* If value==NULL, unset in (remove from) config,
2729
- * if value_regex!=NULL, disregard key/value pairs where value does not match.
2730
- * if value_regex==CONFIG_REGEX_NONE, do not match any existing values
2729
+ * if value_pattern!=NULL, disregard key/value pairs where value does not match.
2730
+ * if value_pattern==CONFIG_REGEX_NONE, do not match any existing values
2731
* (only add a new one)
2732
* if flags contains the CONFIG_FLAGS_MULTI_REPLACE flag, all matching
2733
* key/values are removed before a single new pair is written. If the
2751
*/
2752
int git_config_set_multivar_in_file_gently(const char *config_filename,
2753
const char *key, const char *value,
2754
- const char *value_regex,
2754
+ const char *value_pattern,
2755
unsigned flags)
2756
{
2757
int fd = -1, in_fd = -1;
2812
int i, new_line = 0;
2813
struct config_options opts;
2814
2815
- if (value_regex == NULL)
2816
- store.value_regex = NULL;
2817
- else if (value_regex == CONFIG_REGEX_NONE)
2818
- store.value_regex = CONFIG_REGEX_NONE;
2815
+ if (value_pattern == NULL)
2816
+ store.value_pattern = NULL;
2817
+ else if (value_pattern == CONFIG_REGEX_NONE)
2818
+ store.value_pattern = CONFIG_REGEX_NONE;
2819
else {
2820
- if (value_regex[0] == '!') {
2820
+ if (value_pattern[0] == '!') {
2821
store.do_not_match = 1;
2822
- value_regex++;
2822
+ value_pattern++;
2823
} else
2824
store.do_not_match = 0;
2825
2826
- store.value_regex = (regex_t*)xmalloc(sizeof(regex_t));
2827
- if (regcomp(store.value_regex, value_regex,
2826
+ store.value_pattern = (regex_t*)xmalloc(sizeof(regex_t));
2827
+ if (regcomp(store.value_pattern, value_pattern,
2828
REG_EXTENDED)) {
2829
- error(_("invalid pattern: %s"), value_regex);
2830
- FREE_AND_NULL(store.value_regex);
2829
+ error(_("invalid pattern: %s"), value_pattern);
2830
+ FREE_AND_NULL(store.value_pattern);
2831
ret = CONFIG_INVALID_PATTERN;
2832
goto out_free;
2833
}
2997
2998
void git_config_set_multivar_in_file(const char *config_filename,
2999
const char *key, const char *value,
3000
- const char *value_regex, unsigned flags)
3000
+ const char *value_pattern, unsigned flags)
3001
{
3002
if (!git_config_set_multivar_in_file_gently(config_filename, key, value,
3003
- value_regex, flags))
3003
+ value_pattern, flags))
3004
return;
3005
if (value)
3006
die(_("could not set '%s' to '%s'"), key, value);
3009
}
3010
3011
int git_config_set_multivar_gently(const char *key, const char *value,
3012
- const char *value_regex, unsigned flags)
3012
+ const char *value_pattern, unsigned flags)
3013
{
3014
- return git_config_set_multivar_in_file_gently(NULL, key, value, value_regex,
3014
+ return git_config_set_multivar_in_file_gently(NULL, key, value, value_pattern,
3015
flags);
3016
}
3017
3018
void git_config_set_multivar(const char *key, const char *value,
3019
- const char *value_regex, unsigned flags)
3019
+ const char *value_pattern, unsigned flags)
3020
{
3021
- git_config_set_multivar_in_file(NULL, key, value, value_regex,
3021
+ git_config_set_multivar_in_file(NULL, key, value, value_pattern,
3022
flags);
3023
}
3024