Skip to content

config: move pack size limit into repo config - #2271

Open
Joiejoie1 wants to merge 2 commits into
gitgitgadget:masterfrom
Joiejoie1:outreachy/global-state-mini
Open

Joiejoie1 wants to merge 2 commits into
gitgitgadget:masterfrom
Joiejoie1:outreachy/global-state-mini

Conversation

@Joiejoie1

@Joiejoie1 Joiejoie1 commented Oct 20, 2026 •

Copy link
Copy Markdown

This series moves pack.packsizelimit from a standalone global variable into struct repo_config_values, as part of the ongoing effort to reduce Git's reliance on global state and make its code easier to reuse as a library.

The series includes two patches:

  1. Update repo_config_values_init() to use memset() for zero-initialization, while keeping the defaults that require explicit values.
  2. Move the pack size limit into repo_config_values and update the relevant code to read it from there.

Changes since v1

Thanks to Patrick Steinhardt for reviewing the first version and suggesting the initialization cleanup.

Following his feedback, I've:

  • Added a preparatory patch to simplify how repository configuration values are initialized.
  • Reworked the main commit message to explain the existing problem before describing the change.
  • Removed the need to explicitly initialize the new pack size limit field to zero.

Testing

I built Git and ran the relevant configuration and pack-object tests:

  • make -j2 — passed.
  • t1300-config.sh — 518 successful tests.
  • t5300-pack-object.sh — 63 passed, 2 skipped, 0 failed.

Both test runs reported permission errors during cleanup after the tests had completed.

CC: Patrick Steinhardt <ps@pks.im>, Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>, Christian Couder <christian.couder@gmail.com>, Usman Akinyemi <usmanakinyemi202@gmail.com>
cc: Joie Joie soniqjjj@gmail.com
cc: Patrick Steinhardt ps@pks.im

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

Welcome to GitGitGadget

Hi @Joiejoie1, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that either:

  • Your Pull Request has a good description, if it consists of multiple commits, as it will be used as cover letter.
  • Your Pull Request description is empty, if it consists of a single commit, as the commit message should be descriptive enough by itself.

You can CC potential reviewers by adding a footer to the PR description with the following syntax:

CC: Revi Ewer <revi.ewer@example.com>, Ill Takalook <ill.takalook@example.net>

NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description,
because it will result in a malformed CC list on the mailing list. See
example.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "revisions:" to state which subsystem the change is about, and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form /allow. A good way to find other contributors is to locate recent pull requests where someone has been /allowed:

Both the person who commented /allow and the PR author are able to /allow you.

An alternative is the channel #git-devel on the Libera Chat IRC network:

<newcontributor> I've just created my first PR, could someone please /allow me? https://github.com/gitgitgadget/git/pull/12345
<veteran> newcontributor: it is done
<newcontributor> thanks!

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

If you want to see what email(s) would be sent for a /submit request, add a PR comment /preview to have the email(s) sent to you. You must have a public GitHub email address for this. Note that any reviewers CC'd via the list in the PR description will not actually be sent emails.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail).

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the (raw) link), then import it into your mail program. If you use GMail, you can do this via:

curl -g --user "<EMailAddress>:<Password>" \
    --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

To iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description):

Changes since v1:
- Fixed a typo in the commit message (found by ...)
- Added a code comment to ... as suggested by ...
...

To send a new iteration, just add another PR comment with the contents: /submit.

Need help?

New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join.

You may also be able to find help in real time in the developer IRC channel, #git-devel on Libera Chat. Remember that IRC does not support offline messaging, so if you send someone a private message and log out, they cannot respond to you. The scrollback of #git-devel is archived, though.

@Joiejoie1
Joiejoie1 force-pushed the outreachy/global-state-mini branch from b06d921 to 8013ea0 Compare October 20, 2026 15:32
@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

There is an issue in commit 8013ea0:
config: move pack size limit into repo config

  • Lines in the body of the commit messages should be wrapped between 60 and 76 characters.
    Indented lines, and lines without whitespace, are exempt

@Joiejoie1
Joiejoie1 force-pushed the outreachy/global-state-mini branch from 8013ea0 to e3e36c3 Compare October 20, 2026 15:51
@dscho

dscho commented Oct 20, 2026

Copy link
Copy Markdown
Member

/allow

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

User Joiejoie1 is now allowed to use GitGitGadget.

@Joiejoie1

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

Preview email sent as pull.2271.git.1792514748146.gitgitgadget@gmail.com

@Joiejoie1

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

Preview email sent as pull.2271.git.1792519549513.gitgitgadget@gmail.com

@Joiejoie1

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

Preview email sent as pull.2271.git.1792522164276.gitgitgadget@gmail.com

@Joiejoie1

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

Submitted as pull.2271.git.1792522587065.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2271/Joiejoie1/outreachy/global-state-mini-v1

To fetch this version to local tag pr-2271/Joiejoie1/outreachy/global-state-mini-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2271/Joiejoie1/outreachy/global-state-mini-v1

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

"Kristoffer Haugsbakk" wrote on the Git mailing list (how to reply to this email):

On Tue, Oct 20, 2026, at 20:56, Joy via GitGitGadget wrote:
> From: Joy Gundu <soniqjjj@gmail.com>
>
> [...]
>
> This change removes one piece of global configuration state from Git
> and helps make Git code easier to reuse as a library component.

It's nice to see a paragraph explaining the
overall project in plain terms. Not just
"we are getting rid of globals" or "this is
libification".

>
> Signed-off-by: Joy Gundu <soniqjjj@gmail.com>
> [...]

Sent from mobile

@gitgitgadget

gitgitgadget Bot commented Oct 20, 2026

Copy link
Copy Markdown

User "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> has been added to the cc: list.

@gitgitgadget

gitgitgadget Bot commented Oct 21, 2026

Copy link
Copy Markdown

Patrick Steinhardt wrote on the Git mailing list (how to reply to this email):

On Tue, Oct 20, 2026 at 06:56:27PM +0000, Joy via GitGitGadget wrote:
> 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.

The commit message typically starts with an observation, followed by an
explanation what's bad about the observed status quo and then finally
explains how that state is improved. The order you have here does not
match that typical flow.

> diff --git a/environment.c b/environment.c
> index c83cf44839..e350d6949e 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -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;

Hmm, quite annoying that we need to explicitly zero out all these
fields. Maybe we should adapt `repo_config_values_init()` to first
`memset(cfg, 0, sizeof(*cfg))`? That would allow us to remove a lot of
assignments. If you want to do that, it would be great to do it as a
preparatory patch in the same series.

Other than that the diff looks exactly the same as a local patch I had
already written myself, so thanks for allowing me to worry about one
less thing :)

Patrick

@gitgitgadget

gitgitgadget Bot commented Oct 21, 2026

Copy link
Copy Markdown

User Patrick Steinhardt <ps@pks.im> has been added to the cc: list.

Signed-off-by: Joy Gundu <soniqjjj@gmail.com>
@Joiejoie1
Joiejoie1 force-pushed the outreachy/global-state-mini branch from e3e36c3 to a2d8165 Compare October 21, 2026 14:03
@Joiejoie1

Copy link
Copy Markdown
Author

/preview

1 similar comment
@Joiejoie1

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Oct 21, 2026

Copy link
Copy Markdown

Preview email sent as pull.2271.v2.git.1792596636.gitgitgadget@gmail.com

@gitgitgadget

gitgitgadget Bot commented Oct 21, 2026

Copy link
Copy Markdown

Preview email sent as pull.2271.v2.git.1792597400.gitgitgadget@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>
@Joiejoie1
Joiejoie1 force-pushed the outreachy/global-state-mini branch from a2d8165 to 05ae50b Compare October 21, 2026 15:49
@Joiejoie1

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Oct 21, 2026

Copy link
Copy Markdown

Preview email sent as pull.2271.v2.git.1792598771.gitgitgadget@gmail.com

@gitgitgadget

gitgitgadget Bot commented Oct 21, 2026

Copy link
Copy Markdown

Joie Joie wrote on the Git mailing list (how to reply to this email):

Hi Patrick,

Thanks for the feedback! I’ll take a closer look at zero-initializing
repo_config_values and see if it makes sense to include it as a
preparatory patch.

I’ll also keep your advice on commit message structure in mind for
future patches.

Thanks again for taking the time to review my work!

Best,
Joy


On Wed, Oct 21, 2026 at 9:09 AM Patrick Steinhardt <ps@pks.im> wrote:
>
> On Tue, Oct 20, 2026 at 06:56:27PM +0000, Joy via GitGitGadget wrote:
> > 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.
>
> The commit message typically starts with an observation, followed by an
> explanation what's bad about the observed status quo and then finally
> explains how that state is improved. The order you have here does not
> match that typical flow.
>
> > diff --git a/environment.c b/environment.c
> > index c83cf44839..e350d6949e 100644
> > --- a/environment.c
> > +++ b/environment.c
> > @@ -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;
>
> Hmm, quite annoying that we need to explicitly zero out all these
> fields. Maybe we should adapt `repo_config_values_init()` to first
> `memset(cfg, 0, sizeof(*cfg))`? That would allow us to remove a lot of
> assignments. If you want to do that, it would be great to do it as a
> preparatory patch in the same series.
>
> Other than that the diff looks exactly the same as a local patch I had
> already written myself, so thanks for allowing me to worry about one
> less thing :)
>
> Patrick

@gitgitgadget

gitgitgadget Bot commented Oct 21, 2026

Copy link
Copy Markdown

User Joie Joie <soniqjjj@gmail.com> has been added to the cc: list.

@Joiejoie1

Copy link
Copy Markdown
Author

The Windows win test (3) job was cancelled after reaching 360 minutes. The log shows that it reached the test execution stage, but I couldn't find an individual test failure before cancellation. All other Windows test shards and the Linux/macOS checks passed. Is this a known CI timeout, or would you recommend investigating a particular test in this slice?

@Joiejoie1

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Oct 22, 2026

Copy link
Copy Markdown

Submitted as pull.2271.v2.git.1792662432.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2271/Joiejoie1/outreachy/global-state-mini-v2

To fetch this version to local tag pr-2271/Joiejoie1/outreachy/global-state-mini-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2271/Joiejoie1/outreachy/global-state-mini-v2

@dscho

dscho commented Oct 22, 2026

Copy link
Copy Markdown
Member

The Windows win test (3) job was cancelled after reaching 360 minutes. The log shows that it reached the test execution stage, but I couldn't find an individual test failure before cancellation. All other Windows test shards and the Linux/macOS checks passed. Is this a known CI timeout, or would you recommend investigating a particular test in this slice?

Yes, sadly some of the Windows jobs in particular "loose connection" and then time out.

Comment thread environment.c
@@ -752,34 +752,24 @@ int git_default_config(const char *var, const char *value,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patrick Steinhardt wrote on the Git mailing list (how to reply to this email):

On Thu, Oct 22, 2026 at 09:47:11AM +0000, Joy Gundu via GitGitGadget wrote:
> From: Joy Gundu <soniqjjj@gmail.com>

Even though the patch speaks for itself, we typically still like to a
sentence or two in the commit message itself. E.g.:

    When initializing `struct repo_config_values` we manually zero out a
    lot of its members, which is tedious. Reduce the boilerplate by first
    zeroing out the whole structure so that we only have to set those
    members that have a non-zero default value.

> Signed-off-by: Joy Gundu <soniqjjj@gmail.com>
> ---
>  environment.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/environment.c b/environment.c
> index c83cf44839..89af09aa40 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -752,34 +752,24 @@ int git_default_config(const char *var, const char *value,
>  
>  void repo_config_values_init(struct repo_config_values *cfg)
>  {
> +	memset(cfg, 0, sizeof(*cfg));
> +
>  	/* section "core" config values */
> -	cfg->attributes_file = NULL;
> -	cfg->excludes_file = NULL;
> -	cfg->editor_program = NULL;
> -	cfg->pager_program = NULL;
> -	cfg->askpass_program = NULL;
> -	cfg->apply_default_whitespace = NULL;
> -	cfg->apply_default_ignorewhitespace = NULL;
>  	cfg->push_default = PUSH_DEFAULT_UNSPECIFIED;
>  	cfg->autorebase = AUTOREBASE_NEVER;
>  	cfg->object_creation_mode = OBJECT_CREATION_MODE;
> -	cfg->apply_sparse_checkout = 0;
>  	cfg->trust_ctime = 1;
>  	cfg->check_stat = 1;
>  	cfg->zlib_compression_level = Z_BEST_SPEED;
>  	cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
>  	cfg->precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
> -	cfg->core_sparse_checkout_cone = 0;
>  	cfg->warn_on_object_refname_ambiguity = 1;
>  	cfg->protect_hfs = PROTECT_HFS_DEFAULT;
>  	cfg->protect_ntfs = PROTECT_NTFS_DEFAULT;
> -	cfg->ignore_case = 0;
>  	cfg->trust_executable_bit = 1;
>  	cfg->has_symlinks = platform_has_symlinks();
> -	cfg->use_nanosec = 0;
>  
>  	/* section "sparse" config values */
> -	cfg->sparse_expect_files_outside_of_patterns = 0;

We should probably drop this comment together with the code.

>  	/* section "branch" config values */
>  	cfg->branch_track = BRANCH_TRACK_REMOTE;

Other than that this looks good to me.

Patrick

@gitgitgadget

gitgitgadget Bot commented Oct 22, 2026

Copy link
Copy Markdown

User Patrick Steinhardt <ps@pks.im> has been added to the cc: list.

Comment thread builtin/pack-objects.c
@@ -5370,7 +5370,7 @@ int cmd_pack_objects(int argc,
if (!HAVE_THREADS && delta_search_threads != 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patrick Steinhardt wrote on the Git mailing list (how to reply to this email):

On Thu, Oct 22, 2026 at 09:47:12AM +0000, Joy Gundu via GitGitGadget wrote:
> 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.

This reads well to me, thanks.

Patrick

@gitgitgadget

gitgitgadget Bot commented Oct 22, 2026

Copy link
Copy Markdown

Patrick Steinhardt wrote on the Git mailing list (how to reply to this email):

On Thu, Oct 22, 2026 at 09:47:10AM +0000, Joy via GitGitGadget wrote:
> Changes since v1
> ================
> 
> Thanks to Patrick Steinhardt for reviewing the first version and suggesting
> the initialization cleanup.
> 
> Following his feedback, I've:
> 
>  * Added a preparatory patch to simplify how repository configuration values
>    are initialized.
>  * Reworked the main commit message to explain the existing problem before
>    describing the change.
>  * Removed the need to explicitly initialize the new pack size limit field
>    to zero.

I've got two more small nits on the first patch that you probably want
to address, but other than that this looks as expected to me. Thanks!

Patrick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants