[PATCH v2 2/2] config: move pack size limit into repo config
- From
- Joy Gundu via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Oct 22, 2026, 09:47 UTC
- Message-ID
- <05ae50b5daf0caea8666b0b7c8aaeb9f5c397017.1792662432.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2271.v2.git.1792662432.gitgitgadget@gmail.com>
From: Joy Gundu <soniqjjj@gmail.com>
The pack size limit is currently stored in a standalone global variable, even though it is repository configuration.
Move the value into repo_config_values and update the configuration parser and pack-writing code to read it from the repository's configuration values.
This removes one piece of global configuration state and helps make Git code easier to reuse as a library component.
Signed-off-by: Joy Gundu <soniqjjj@gmail.com> --- builtin/pack-objects.c | 2 +- environment.c | 3 +-- environment.h | 3 +-- object-file.c | 6 ++++-- 4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index ca3a891dfb..1bd6b2d566 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -5370,7 +5370,7 @@ int cmd_pack_objects(int argc, if (!HAVE_THREADS && delta_search_threads != 1) warning(_("no threads support, ignoring --threads")); if (!pack_to_stdout && !pack_size_limit) - pack_size_limit = pack_size_limit_cfg; + pack_size_limit = cfg->pack_size_limit; if (pack_to_stdout && pack_size_limit) die(_("--max-pack-size cannot be used to build a pack for transfer")); if (pack_size_limit && pack_size_limit < 1024*1024) { diff --git a/environment.c b/environment.c index 89af09aa40..77bbbb7649 100644 --- a/environment.c +++ b/environment.c @@ -57,7 +57,6 @@ char *check_roundtrip_encoding; #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS #endif int grafts_keep_true_parents; -unsigned long pack_size_limit_cfg; #ifndef PROTECT_HFS_DEFAULT #define PROTECT_HFS_DEFAULT 0 @@ -728,7 +727,7 @@ int git_default_config(const char *var, const char *value, } if (!strcmp(var, "pack.packsizelimit")) { - pack_size_limit_cfg = git_config_ulong(var, value, ctx->kvi); + cfg->pack_size_limit = git_config_ulong(var, value, ctx->kvi); return 0; } diff --git a/environment.h b/environment.h index b336459e90..070314f7ef 100644 --- a/environment.h +++ b/environment.h @@ -132,6 +132,7 @@ struct repo_config_values { int check_stat; int zlib_compression_level; int pack_compression_level; + unsigned long pack_size_limit; int precomposed_unicode; int core_sparse_checkout_cone; int warn_on_object_refname_ambiguity; @@ -235,8 +236,6 @@ int have_git_dir(void); /* Environment bits from configuration mechanism */ extern int minimum_abbrev, default_abbrev; extern int assume_unchanged; -extern unsigned long pack_size_limit_cfg; - extern int grafts_keep_true_parents; const char *get_log_output_encoding(void); diff --git a/object-file.c b/object-file.c index c049bf13f7..7f55e6331f 100644 --- a/object-file.c +++ b/object-file.c @@ -882,6 +882,8 @@ static int odb_transaction_files_write_object_stream(struct odb_transaction *bas struct odb_transaction_files, base); struct transaction_packfile *state = &transaction->packfile; + struct repo_config_values *cfg = + repo_config_values(the_repository); struct git_hash_ctx ctx; unsigned char obuf[16384]; unsigned header_len; @@ -903,8 +905,8 @@ static int odb_transaction_files_write_object_stream(struct odb_transaction *bas * the difference between the inflated and on-disk size is limited * to zlib compression and is sufficient for this check. */ - if (state->nr_written && pack_size_limit_cfg && - pack_size_limit_cfg < state->offset + stream->size) { + if (state->nr_written && cfg->pack_size_limit && + cfg->pack_size_limit < state->offset + stream->size) { flush_packfile_transaction(transaction); odb_reprepare(transaction->base.source->odb); }
-- gitgitgadget