From: Tian Yuchen <a3205153416@gmail•com>
To: Olamide Caleb Bello <belkid98@gmail•com>, git@vger•kernel.org
Cc: toon@iotcl•com, phillip.wood123@gmail•com, gitster@pobox•com,
christian.couder@gmail•com, usmanakinyemi202@gmail•com,
kaartic.sivaraam@gmail•com, me@ttaylorr•com,
karthik.188@gmail•com
Subject: Re: [PATCH v1 0/8] repo_config_values: migrate more globals
Date: Thu, 12 Mar 2026 13:03:11 +0800 [thread overview]
Message-ID: <9f9a2e8e-6db7-4105-ba2b-7e42bff2ad1a@gmail.com> (raw)
In-Reply-To: <cover.1773127785.git.belkid98@gmail.com>
Hi Olamide,
On 3/10/26 20:06, Olamide Caleb Bello wrote:
> 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).
> @@ -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
next prev parent reply other threads:[~2026-03-12 5:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 12:06 [PATCH v1 0/8] repo_config_values: migrate more globals Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 1/8] environment: move "trust_ctime" into `struct repo_config_values` Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 2/8] environment: move "check_stat" " Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 3/8] environment: move `zlib_compression_level` into repo_config_values Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 4/8] environment: move "pack_compression_level" into `struct repo_config_values` Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 5/8] environment: move "precomposed_unicode" " Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 6/8] env: move "core_sparse_checkout_cone" " Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 7/8] env: put "sparse_expect_files_outside_of_patterns" in `repo_config_values` Olamide Caleb Bello
2026-03-10 12:06 ` [PATCH v1 8/8] env: move "warn_on_object_refname_ambiguity" into `repo_config_values` Olamide Caleb Bello
2026-03-10 12:31 ` [PATCH v1 0/8] repo_config_values: migrate more globals Christian Couder
2026-03-12 12:55 ` Bello Olamide
2026-03-12 5:03 ` Tian Yuchen [this message]
2026-03-12 12:46 ` Bello Olamide
2026-03-12 13:18 ` Bello Olamide
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=9f9a2e8e-6db7-4105-ba2b-7e42bff2ad1a@gmail.com \
--to=a3205153416@gmail$(echo .)com \
--cc=belkid98@gmail$(echo .)com \
--cc=christian.couder@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=kaartic.sivaraam@gmail$(echo .)com \
--cc=karthik.188@gmail$(echo .)com \
--cc=me@ttaylorr$(echo .)com \
--cc=phillip.wood123@gmail$(echo .)com \
--cc=toon@iotcl$(echo .)com \
--cc=usmanakinyemi202@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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