Skip to content

Commit 0c2c37d

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 44ebcd6 commit 0c2c37d

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

builtin/fast-import.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,8 +3481,8 @@ static void git_pack_config(void)
34813481
if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
34823482
pack_idx_opts.version = indexversion_value;
34833483
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);
34863486
}
34873487
if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value))
34883488
max_packsize = packsizelimit_value;

builtin/notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ static int git_config_get_notes_strategy(const char *key,
868868
if (git_config_get_string(key, &value))
869869
return 1;
870870
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);
872872

873873
free(value);
874874
return 0;

config.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,7 @@ int repo_config_get_string(struct repository *repo,
26112611
git_config_check_init(repo);
26122612
ret = git_configset_get_string(repo->config, key, dest);
26132613
if (ret < 0)
2614-
git_die_config(key, NULL);
2614+
git_die_config(repo, key, NULL);
26152615
return ret;
26162616
}
26172617

@@ -2622,7 +2622,7 @@ int repo_config_get_string_tmp(struct repository *repo,
26222622
git_config_check_init(repo);
26232623
ret = git_configset_get_string_tmp(repo->config, key, dest);
26242624
if (ret < 0)
2625-
git_die_config(key, NULL);
2625+
git_die_config(repo, key, NULL);
26262626
return ret;
26272627
}
26282628

@@ -2668,7 +2668,7 @@ int repo_config_get_pathname(struct repository *repo,
26682668
git_config_check_init(repo);
26692669
ret = git_configset_get_pathname(repo->config, key, dest);
26702670
if (ret < 0)
2671-
git_die_config(key, NULL);
2671+
git_die_config(repo, key, NULL);
26722672
return ret;
26732673
}
26742674

@@ -2774,7 +2774,7 @@ int repo_config_get_expiry(struct repository *r, const char *key, const char **o
27742774
if (strcmp(*output, "now")) {
27752775
timestamp_t now = approxidate("now");
27762776
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);
27782778
}
27792779
return ret;
27802780
}
@@ -2858,7 +2858,7 @@ void git_die_config_linenr(const char *key, const char *filename, int linenr)
28582858
key, filename, linenr);
28592859
}
28602860

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, ...)
28622862
{
28632863
const struct string_list *values;
28642864
struct key_value_info *kv_info;
@@ -2870,7 +2870,7 @@ void git_die_config(const char *key, const char *err, ...)
28702870
error_fn(err, params);
28712871
va_end(params);
28722872
}
2873-
if (git_config_get_value_multi(key, &values))
2873+
if (repo_config_get_value_multi(r, key, &values))
28742874
BUG("for key '%s' we must have a value to report on", key);
28752875
kv_info = values->items[values->nr - 1].util;
28762876
git_die_config_linenr(key, kv_info->filename, kv_info->linenr);

config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ int repo_config_get_expiry_in_days(struct repository *r, const char *key,
726726
* dies printing the line number and the file name of the highest priority
727727
* value for the configuration variable `key`.
728728
*/
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)));
730731

731732
/**
732733
* Helper function which formats the die error message according to the

0 commit comments

Comments
 (0)