From: Tian Yuchen <cat@malon.dev>
To: git@vger.kernel.org
Cc: ps@pks.im, Tian Yuchen <cat@malon.dev>,
Christian Couder <christian.couder@gmail.com>,
Ayush Chandekar <ayu.chandekar@gmail.com>,
Olamide Caleb Bello <belkid98@gmail.com>
Subject: [PATCH v2 1/2] environment: migrate pack_size_limit_cfg into repo_config_values
Date: Tue, 28 Jul 2026 09:46:29 +0800 [thread overview]
Message-ID: <20260728014630.3284974-2-cat@malon.dev> (raw)
In-Reply-To: <20260728014630.3284974-1-cat@malon.dev>
Move the global 'pack_size_limit_cfg' configuration into the
repository-specific 'repo_config_values' struct.
We do not introduce a getter for it because the readers are
limited and no hardcoded fallback values are needed.
Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Ayush Chandekar <ayu.chandekar@gmail.com>
Mentored-by: Olamide Caleb Bello <belkid98@gmail.com>
Signed-off-by: Tian Yuchen <cat@malon.dev>
---
builtin/pack-objects.c | 2 +-
environment.c | 4 ++--
environment.h | 3 ++-
object-file.c | 5 +++--
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3673b14b89..4ebcaccb09 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5328,7 +5328,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_cfg;
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 c663113e8a..53623518c7 100644
--- a/environment.c
+++ b/environment.c
@@ -67,7 +67,6 @@ enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
#endif
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
int grafts_keep_true_parents;
-unsigned long pack_size_limit_cfg;
#ifndef PROTECT_HFS_DEFAULT
#define PROTECT_HFS_DEFAULT 0
@@ -704,7 +703,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_cfg = git_config_ulong(var, value, ctx->kvi);
return 0;
}
@@ -742,4 +741,5 @@ void repo_config_values_init(struct repo_config_values *cfg)
cfg->core_sparse_checkout_cone = 0;
cfg->sparse_expect_files_outside_of_patterns = 0;
cfg->warn_on_object_refname_ambiguity = 1;
+ cfg->pack_size_limit_cfg = 0;
}
diff --git a/environment.h b/environment.h
index acfb670be1..2e0f8beac0 100644
--- a/environment.h
+++ b/environment.h
@@ -101,6 +101,8 @@ struct repo_config_values {
int protect_hfs;
int protect_ntfs;
int ignore_case;
+ unsigned long pack_size_limit_cfg;
+
/* section "sparse" config values */
int sparse_expect_files_outside_of_patterns;
@@ -184,7 +186,6 @@ extern int minimum_abbrev, default_abbrev;
extern int assume_unchanged;
extern char *apply_default_whitespace;
extern char *apply_default_ignorewhitespace;
-extern unsigned long pack_size_limit_cfg;
enum rebase_setup_type {
AUTOREBASE_NEVER = 0,
diff --git a/object-file.c b/object-file.c
index 7ff2b730ac..be68eead63 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1273,6 +1273,7 @@ static int odb_transaction_files_write_object_stream(struct odb_transaction *bas
size_t size,
struct object_id *result_oid)
{
+ struct repo_config_values *cfg = repo_config_values(the_repository);
struct odb_transaction_files *transaction = container_of(base,
struct odb_transaction_files,
base);
@@ -1298,8 +1299,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 + size)
+ if (state->nr_written && cfg->pack_size_limit_cfg &&
+ cfg->pack_size_limit_cfg < state->offset + size)
flush_packfile_transaction(transaction);
CALLOC_ARRAY(idx, 1);
--
2.43.0
next prev parent reply other threads:[~2026-07-28 1:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 11:54 [PATCH v1 0/3] environment: migrate more global variables, pt.2 Tian Yuchen
2026-07-25 11:54 ` [PATCH v1 1/3] environment: migrate minimum_abbrev and default_abbrev Tian Yuchen
2026-07-25 11:54 ` [PATCH v1 2/3] environment: migrate pack_size_limit_cfg into repo_config_values Tian Yuchen
2026-07-25 11:54 ` [PATCH v1 3/3] environment: migrate assume_unchanged " Tian Yuchen
2026-07-25 17:02 ` [PATCH v1 0/3] environment: migrate more global variables, pt.2 Junio C Hamano
2026-07-26 6:29 ` Tian Yuchen
2026-07-28 1:46 ` [PATCH v2 0/2] environment: migrate more global variables into Tian Yuchen
2026-07-28 1:46 ` Tian Yuchen [this message]
2026-07-28 1:46 ` [PATCH v2 2/2] environment: migrate assume_unchanged into repo_config_values Tian Yuchen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260728014630.3284974-2-cat@malon.dev \
--to=cat@malon.dev \
--cc=ayu.chandekar@gmail.com \
--cc=belkid98@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox