config: pass repo to `git_die_config()`
Refactor `git_die_config()` to accept a `struct repository` such that we can get rid of the implicit dependency on `the_repository`. Rename the function accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
44ebcd6254
commit
0c2c37d16b
|
@ -3481,8 +3481,8 @@ static void git_pack_config(void)
|
|||
if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
|
||||
pack_idx_opts.version = indexversion_value;
|
||||
if (pack_idx_opts.version > 2)
|
||||
git_die_config("pack.indexversion",
|
||||
"bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
|
||||
git_die_config(the_repository, "pack.indexversion",
|
||||
"bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
|
||||
}
|
||||
if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value))
|
||||
max_packsize = packsizelimit_value;
|
||||
|
|
|
@ -868,7 +868,7 @@ static int git_config_get_notes_strategy(const char *key,
|
|||
if (git_config_get_string(key, &value))
|
||||
return 1;
|
||||
if (parse_notes_merge_strategy(value, strategy))
|
||||
git_die_config(key, _("unknown notes merge strategy %s"), value);
|
||||
git_die_config(the_repository, key, _("unknown notes merge strategy %s"), value);
|
||||
|
||||
free(value);
|
||||
return 0;
|
||||
|
|
12
config.c
12
config.c
|
@ -2611,7 +2611,7 @@ int repo_config_get_string(struct repository *repo,
|
|||
git_config_check_init(repo);
|
||||
ret = git_configset_get_string(repo->config, key, dest);
|
||||
if (ret < 0)
|
||||
git_die_config(key, NULL);
|
||||
git_die_config(repo, key, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2622,7 +2622,7 @@ int repo_config_get_string_tmp(struct repository *repo,
|
|||
git_config_check_init(repo);
|
||||
ret = git_configset_get_string_tmp(repo->config, key, dest);
|
||||
if (ret < 0)
|
||||
git_die_config(key, NULL);
|
||||
git_die_config(repo, key, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2668,7 +2668,7 @@ int repo_config_get_pathname(struct repository *repo,
|
|||
git_config_check_init(repo);
|
||||
ret = git_configset_get_pathname(repo->config, key, dest);
|
||||
if (ret < 0)
|
||||
git_die_config(key, NULL);
|
||||
git_die_config(repo, key, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2774,7 +2774,7 @@ int repo_config_get_expiry(struct repository *r, const char *key, const char **o
|
|||
if (strcmp(*output, "now")) {
|
||||
timestamp_t now = approxidate("now");
|
||||
if (approxidate(*output) >= now)
|
||||
git_die_config(key, _("Invalid %s: '%s'"), key, *output);
|
||||
git_die_config(r, key, _("Invalid %s: '%s'"), key, *output);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -2858,7 +2858,7 @@ void git_die_config_linenr(const char *key, const char *filename, int linenr)
|
|||
key, filename, linenr);
|
||||
}
|
||||
|
||||
void git_die_config(const char *key, const char *err, ...)
|
||||
void git_die_config(struct repository *r, const char *key, const char *err, ...)
|
||||
{
|
||||
const struct string_list *values;
|
||||
struct key_value_info *kv_info;
|
||||
|
@ -2870,7 +2870,7 @@ void git_die_config(const char *key, const char *err, ...)
|
|||
error_fn(err, params);
|
||||
va_end(params);
|
||||
}
|
||||
if (git_config_get_value_multi(key, &values))
|
||||
if (repo_config_get_value_multi(r, key, &values))
|
||||
BUG("for key '%s' we must have a value to report on", key);
|
||||
kv_info = values->items[values->nr - 1].util;
|
||||
git_die_config_linenr(key, kv_info->filename, kv_info->linenr);
|
||||
|
|
3
config.h
3
config.h
|
@ -726,7 +726,8 @@ int repo_config_get_expiry_in_days(struct repository *r, const char *key,
|
|||
* dies printing the line number and the file name of the highest priority
|
||||
* value for the configuration variable `key`.
|
||||
*/
|
||||
NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
|
||||
NORETURN void git_die_config(struct repository *r, const char *key, const char *err, ...)
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
|
||||
/**
|
||||
* Helper function which formats the die error message according to the
|
||||
|
|
Loading…
Reference in New Issue