environment: move access to "core.bigFileThreshold" into repo settings

The "core.bigFileThreshold" setting is stored in a global variable and
populated via `git_default_core_config()`. This may cause issues in
the case where one is handling multiple different repositories in a
single process with different values for that config key, as we may or
may not see the correct value in that case. Furthermore, global state
blocks our path towards libification.

Refactor the code so that we instead store the value in `struct
repo_settings`, where the value is computed as-needed and cached.

Note that this change requires us to adapt one test in t1050 that
verifies that we die when parsing an invalid "core.bigFileThreshold"
value. The exercised Git command doesn't use the value at all, and thus
it won't hit the new code path that parses the value. This is addressed
by using git-hash-object(1) instead, which does read the value.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-03-10 08:13:23 +01:00
committed by Junio C Hamano
parent 2582846f2f
commit 7835ee75cd
15 changed files with 52 additions and 22 deletions

View File

@@ -553,7 +553,8 @@ static void unpack_one(unsigned nr)
switch (type) {
case OBJ_BLOB:
if (!dry_run && size > big_file_threshold) {
if (!dry_run &&
size > repo_settings_get_big_file_threshold(the_repository)) {
stream_blob(size, nr);
return;
}