Skip to content

[Outreachy PATCH] prune-packed: remove use_the_repository_variable - #2266

Open
shashu8660 wants to merge 1 commit into
gitgitgadget:masterfrom
shashu8660:outreachy2
Open

shashu8660 wants to merge 1 commit into
gitgitgadget:masterfrom
shashu8660:outreachy2

Conversation

@shashu8660

@shashu8660 shashu8660 commented Oct 18, 2026 •

Copy link
Copy Markdown

CC: Kaartic Sivaraam kaartic.sivaraam@gmail.com, Christian Couder christian.couder@gmail.com, Siddharth Asthana siddharthasthana31@gmail.com, Usman Akinyemi usmanakinyemi202@gmail.com, Junio C Hamano gitster@pobox.com
cc: Patrick Steinhardt ps@pks.im

@shashu8660

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Oct 18, 2026

Copy link
Copy Markdown

Preview email sent as pull.2266.git.1792320336845.gitgitgadget@gmail.com

@shashu8660 shashu8660 changed the title prune-packed: remove USE_THE_REPOSITORY_VARIABLE [Outreachy PATCH] prune-packed: remove use_the_repository_variable Oct 18, 2026
@shashu8660

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Oct 18, 2026

Copy link
Copy Markdown

Submitted as pull.2266.git.1792341073005.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2266/shashu8660/outreachy2-v1

To fetch this version to local tag pr-2266/shashu8660/outreachy2-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2266/shashu8660/outreachy2-v1

@gitgitgadget

gitgitgadget Bot commented Oct 19, 2026

Copy link
Copy Markdown

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

On Sun, Oct 18, 2026 at 04:31:12PM +0000, Shashank S via GitGitGadget wrote:
> From: Shashank <shashu8660@gmail.com>
> 
> Right now, the prune_packed_objects() function uses the global

Nit: we typically refrain from saying "now", as it's implicitly clear
that you're describing the status quo in your commit message unless you
explicitly refer to an older commit.

> the_repository variable. To help with the libification effort,
> change this function so it takes a 'struct repository' pointer
> as an argument instead.
> 
> The function for_each_loose_file_in_source() uses a callback
> that only takes a single 'void *data' pointer. This means we
> cannot pass both the repository pointer and the 'opts' integer
> at the same time. To fix this, create a new 'struct prune_data'
> to hold both of them together, and update the prune_subdir() and
> prune_object() callbacks to read from this new struct.
> 
> Update the builtins that call this function (builtin/prune-packed.c,
> builtin/prune.c, and builtin/repack.c) to pass their local `repo`
> variables. Because we are now actually using the 'repo'  parameter
> in these files, we can safely remove the UNUSED macro from them.

The question isn't really whether we can safely remove the UNUSED macro.
The question is rather whether we can assume that `repo` always points
to a proper repository. And for that you need to research whether these
commands can be invoked outside of a repository, because if so the repo
may be `NULL`.

> finally, drop the USE_THE_REPOSITORY_VARIABLE macro from

s/finally/Finally

> prune-packed.c.
> 
> Signed-off-by: Shashank <shashu8660@gmail.com>

We typically ask contributors to spell out their full name, see
Documentation/SubmittingPatches [[real-name]].

The changes all look sensible to me, thanks!

Patrick

@gitgitgadget

gitgitgadget Bot commented Oct 19, 2026

Copy link
Copy Markdown

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

The prune_packed_objects() function uses the global
the_repository variable. To help with the libification effort,
change this function so it takes a 'struct repository' pointer
as an argument instead.

The function for_each_loose_file_in_source() uses a callback
that only takes a single 'void *data' pointer. This means we
cannot pass both the repository pointer and the 'opts' integer
at the same time. To fix this, create a new 'struct prune_data'
to hold both of them together, and update the prune_subdir() and
prune_object() callbacks to read from this new struct.

Update the builtins that call this function (builtin/prune-packed.c,
builtin/prune.c, and builtin/repack.c) to pass their local 'repo'
variables. We can safely remove the UNUSED macro from them because
these commands are all declared with the RUN_SETUP flag in git.c,
which guarantees that the 'repo' pointer will never be NULL.

Finally, drop the USE_THE_REPOSITORY_VARIABLE macro from
prune-packed.c.

Signed-off-by: Shashank S Mogaveera <shashu8660@gmail.com>
@shashu8660

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Oct 19, 2026

Copy link
Copy Markdown

Preview email sent as pull.2266.v2.git.1792428445532.gitgitgadget@gmail.com

@shashu8660

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Oct 19, 2026

Copy link
Copy Markdown

Submitted as pull.2266.v2.git.1792428811100.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2266/shashu8660/outreachy2-v2

To fetch this version to local tag pr-2266/shashu8660/outreachy2-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2266/shashu8660/outreachy2-v2

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant