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

Re: [PATCH v1 0/8] repo_config_values: migrate more globals

From
Tian Yuchen <a3205153416@gmail.com>
Date
Mar 12, 2026, 05:03 UTC
Message-ID
<9f9a2e8e-6db7-4105-ba2b-7e42bff2ad1a@gmail.com>
In-Reply-To
<cover.1773127785.git.belkid98@gmail.com>
Hi Olamide,
On 3/10/26 20:06, Olamide Caleb Bello wrote:
Show 10 quoted lines
>   	int status = Z_OK;
>   	int write_object = (flags & INDEX_WRITE_OBJECT);
>   	off_t offset = 0;
> +	struct repo_config_values *cfg = repo_config_values(the_repository);
>   
> -	git_deflate_init(&s, pack_compression_level);
> +	git_deflate_init(&s, cfg->pack_compression_level);
>   
>   	hdrlen = encode_in_pack_object_header(obuf, sizeof(obuf), OBJ_BLOB, size);
>   	s.next_out = obuf + hdrlen;

I didn't look closely at the other parts, but I have a small question about this section.

pack_compression_level before this patch is a global variable:
	int pack_compression_level = Z_DEFAULT_COMPRESSION;
and struct option  in cmd_pack_objects contains its pointer:
struct option pack_objects_options[] = {
	...
	OPT_INTEGER(0, "compression", &pack_compression_level, ...),
	...
};

The reason why functions such as do_compress, write_large_blob_data can work properly is beacuse they all read the same global variable, right?

However, in this patch,
> +	struct repo_config_values *cfg = repo_config_values(the_repository);
> +	int pack_compression_level = cfg->pack_compression_level;

Here, a local variable with the same name was created via value assignment (I also find the naming a bit odd).

Show 9 quoted lines
> @@ -383,8 +383,9 @@ static unsigned long do_compress(void **pptr, unsigned long size)
>  	git_zstream stream;
>  	void *in, *out;
>  	unsigned long maxsize;
> +	struct repo_config_values *cfg = repo_config_values(the_repository);
>  
> -	git_deflate_init(&stream, pack_compression_level);
> +	git_deflate_init(&stream, cfg->pack_compression_level);
>  	maxsize = git_deflate_bound(&stream, size);

But then in the do_compress() function, the variable being read is still that pointer, cfg->pack_compression_level. The expected input wasn't *written back* to this pointer, right? If I understand correctly, after parsing CLI, the output is written to the local variable rather than the cfg. And that's why the naming is a bit confusing to me.

struct option pack_objects_options[] = {
	...
	OPT_INTEGER(0, "compression", &cfg->pack_compression_level, ...),
	...
};

I think change like this is needed. Of course, you'll need to double-check it. _(:3 」∠ )_

Regards,
Yuchen
Previous: Bello OlamideNext: Bello Olamide
Message 12 of 14 in “repo_config_values: migrate more globals”
  1. 0/8 repo_config_values: migrate more globalsOlamide Caleb Bello, Mar 10, 2026
  2. 1/8 environment: move "trust_ctime" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  3. 2/8 environment: move "check_stat" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  4. 3/8 environment: move `zlib_compression_level` into repo_config_valuesOlamide Caleb Bello, Mar 10, 2026
  5. 4/8 environment: move "pack_compression_level" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  6. 5/8 environment: move "precomposed_unicode" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  7. 6/8 env: move "core_sparse_checkout_cone" into `struct repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  8. 7/8 env: put "sparse_expect_files_outside_of_patterns" in `repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  9. 8/8 env: move "warn_on_object_refname_ambiguity" into `repo_config_values`Olamide Caleb Bello, Mar 10, 2026
  10. Christian CouderMar 10, 2026
  11. Bello OlamideMar 12, 2026
  12. Tian YuchenMar 12, 2026
  13. Bello OlamideMar 12, 2026
  14. Bello OlamideMar 12, 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.