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>
Patrick Steinhardt committed
Aug 13, 2024 at 11:14 UTC
0c2c37d16b170697e7c97be5db7dca58b877c4e5
4 files changed
+11
-10
builtin/fast-import.c
+2
-2
@@ -3481,8 +3481,8 @@ static void git_pack_config(void)
3481
if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
3482
pack_idx_opts.version = indexversion_value;
3483
if (pack_idx_opts.version > 2)
3484
- git_die_config("pack.indexversion",
3485
- "bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
3484
+ git_die_config(the_repository, "pack.indexversion",
3485
+ "bad pack.indexVersion=%"PRIu32, pack_idx_opts.version);
3486
}
3487
if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value))
3488
max_packsize = packsizelimit_value;
builtin/notes.c
+1
-1
@@ -868,7 +868,7 @@ static int git_config_get_notes_strategy(const char *key,
868
if (git_config_get_string(key, &value))
869
return 1;
870
if (parse_notes_merge_strategy(value, strategy))
871
- git_die_config(key, _("unknown notes merge strategy %s"), value);
871
+ git_die_config(the_repository, key, _("unknown notes merge strategy %s"), value);
872
873
free(value);
874
return 0;
config.c
+6
-6
@@ -2611,7 +2611,7 @@ int repo_config_get_string(struct repository *repo,
2611
git_config_check_init(repo);
2612
ret = git_configset_get_string(repo->config, key, dest);
2613
if (ret < 0)
2614
- git_die_config(key, NULL);
2614
+ git_die_config(repo, key, NULL);
2615
return ret;
2616
}
2617
@@ -2622,7 +2622,7 @@ int repo_config_get_string_tmp(struct repository *repo,
2622
git_config_check_init(repo);
2623
ret = git_configset_get_string_tmp(repo->config, key, dest);
2624
if (ret < 0)
2625
- git_die_config(key, NULL);
2625
+ git_die_config(repo, key, NULL);
2626
return ret;
2627
}
2628
@@ -2668,7 +2668,7 @@ int repo_config_get_pathname(struct repository *repo,
2668
git_config_check_init(repo);
2669
ret = git_configset_get_pathname(repo->config, key, dest);
2670
if (ret < 0)
2671
- git_die_config(key, NULL);
2671
+ git_die_config(repo, key, NULL);
2672
return ret;
2673
}
2674
@@ -2774,7 +2774,7 @@ int repo_config_get_expiry(struct repository *r, const char *key, const char **o
2774
if (strcmp(*output, "now")) {
2775
timestamp_t now = approxidate("now");
2776
if (approxidate(*output) >= now)
2777
- git_die_config(key, _("Invalid %s: '%s'"), key, *output);
2777
+ git_die_config(r, key, _("Invalid %s: '%s'"), key, *output);
2778
}
2779
return ret;
2780
}
@@ -2858,7 +2858,7 @@ void git_die_config_linenr(const char *key, const char *filename, int linenr)
2858
key, filename, linenr);
2859
}
2860
2861
-void git_die_config(const char *key, const char *err, ...)
2861
+void git_die_config(struct repository *r, const char *key, const char *err, ...)
2862
{
2863
const struct string_list *values;
2864
struct key_value_info *kv_info;
@@ -2870,7 +2870,7 @@ void git_die_config(const char *key, const char *err, ...)
2870
error_fn(err, params);
2871
va_end(params);
2872
}
2873
- if (git_config_get_value_multi(key, &values))
2873
+ if (repo_config_get_value_multi(r, key, &values))
2874
BUG("for key '%s' we must have a value to report on", key);
2875
kv_info = values->items[values->nr - 1].util;
2876
git_die_config_linenr(key, kv_info->filename, kv_info->linenr);
config.h
+2
-1
@@ -726,7 +726,8 @@ int repo_config_get_expiry_in_days(struct repository *r, const char *key,
726
* dies printing the line number and the file name of the highest priority
727
* value for the configuration variable `key`.
728
*/
729
-NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
729
+NORETURN void git_die_config(struct repository *r, const char *key, const char *err, ...)
730
+ __attribute__((format(printf, 3, 4)));
731
732
/**
733
* Helper function which formats the die error message according to the