All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] config: move pack size limit into repo config
@ 2026-10-20 18:56 Joy via GitGitGadget
  2026-10-20 19:02 ` Kristoffer Haugsbakk
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Joy via GitGitGadget @ 2026-10-20 18:56 UTC (permalink / raw)
  To: git; +Cc: Usman Akinyemi>, Christian Couder>, Joy, Joy Gundu

From: Joy Gundu <soniqjjj@gmail.com>

Store the pack.packsizelimit value in repository configuration
rather than keeping it in a standalone global variable for the repository.

Update the configuration parser and pack-writing code to read
the value from repo_config_values rather than a global variable.

This change removes one piece of global configuration state from Git
and helps make Git code easier to reuse as a library component.

Signed-off-by: Joy Gundu <soniqjjj@gmail.com>
---
    config: move pack size limit into repo config

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2271%2FJoiejoie1%2Foutreachy%2Fglobal-state-mini-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2271/Joiejoie1/outreachy/global-state-mini-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2271

 builtin/pack-objects.c | 2 +-
 environment.c          | 4 ++--
 environment.h          | 3 +--
 object-file.c          | 6 ++++--
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index af9390a46b..1c9044060d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -5380,7 +5380,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 c83cf44839..e350d6949e 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;
 	}
 
@@ -768,6 +767,7 @@ void repo_config_values_init(struct repo_config_values *cfg)
 	cfg->check_stat = 1;
 	cfg->zlib_compression_level = Z_BEST_SPEED;
 	cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
+	cfg->pack_size_limit = 0;
 	cfg->precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
 	cfg->core_sparse_checkout_cone = 0;
 	cfg->warn_on_object_refname_ambiguity = 1;
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 210984f825..3178bd6e65 100644
--- a/object-file.c
+++ b/object-file.c
@@ -885,6 +885,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;
@@ -906,8 +908,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);
 	}

base-commit: c51408889c3b372814bc20b9431c3b74d0d268eb
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-11-03 12:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 18:56 [PATCH] config: move pack size limit into repo config Joy via GitGitGadget
2026-10-20 19:02 ` Kristoffer Haugsbakk
2026-10-21  8:09 ` Patrick Steinhardt
2026-10-21 12:23   ` Joie Joie
2026-10-22  9:47 ` [PATCH v2 0/2] " Joy via GitGitGadget
2026-10-22  9:47   ` [PATCH v2 1/2] repo: zero-initialize configuration values Joy Gundu via GitGitGadget
2026-10-22 11:30     ` Patrick Steinhardt
2026-10-23 12:00       ` Joie Joie
2026-10-26  7:30         ` Patrick Steinhardt
2026-10-22  9:47   ` [PATCH v2 2/2] config: move pack size limit into repo config Joy Gundu via GitGitGadget
2026-10-22 11:30     ` Patrick Steinhardt
2026-10-22 11:30   ` [PATCH v2 0/2] " Patrick Steinhardt
2026-11-03 12:48 ` [PATCH v3 0/2] [Outreachy] " Joy via GitGitGadget
2026-11-03 12:48   ` [PATCH v3 1/2] repo: zero-initialize configuration values Joy Gundu via GitGitGadget
2026-11-03 12:48   ` [PATCH v3 2/2] config: move pack size limit into repo config Joy Gundu via GitGitGadget

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.