git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 2/2] config: move pack size limit into repo config

From
JGJoy Gundu via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 3, 2026, 12:48 UTC
Message-ID
<ba34e82a0a6a99181637e2fe33be5506f2a1bdd0.1793710118.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2271.v3.git.1793710118.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          | 4 +---
 environment.h          | 3 +--
 object-file.c          | 6 ++++--
 4 files changed, 7 insertions(+), 8 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 5a2eb8b2e4..b004029025 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;
 	}
 
@@ -769,7 +768,6 @@ void repo_config_values_init(struct repo_config_values *cfg)
 	cfg->trust_executable_bit = 1;
 	cfg->has_symlinks = platform_has_symlinks();
 
-
 	/* section "branch" config values */
 	cfg->branch_track = BRANCH_TRACK_REMOTE;
 }
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
Previous: Joy Gundu via GitGitGadgetNext: Tanga Joris
Message 15 of 16 in “config: move pack size limit into repo config”
  1. config: move pack size limit into repo configJoy via GitGitGadget, Oct 20, 2026
  2. Kristoffer HaugsbakkOct 20, 2026
  3. Patrick SteinhardtOct 21, 2026
  4. Joie JoieOct 21, 2026
  5. 0/2 config: move pack size limit into repo configJoy via GitGitGadget, Oct 22, 2026
  6. 1/2 repo: zero-initialize configuration valuesJoy Gundu via GitGitGadget, Oct 22, 2026
  7. Patrick SteinhardtOct 22, 2026
  8. Joie JoieOct 23, 2026
  9. Patrick SteinhardtOct 26, 2026
  10. 2/2 config: move pack size limit into repo configJoy Gundu via GitGitGadget, Oct 22, 2026
  11. Patrick SteinhardtOct 22, 2026
  12. Patrick SteinhardtOct 22, 2026
  13. 0/2 [Outreachy] config: move pack size limit into repo configJoy via GitGitGadget, Nov 3, 2026
  14. 1/2 repo: zero-initialize configuration valuesJoy Gundu via GitGitGadget, Nov 3, 2026
  15. 2/2 config: move pack size limit into repo configJoy Gundu via GitGitGadget, Nov 3, 2026
  16. Tanga JorisNov 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.