Repository navigation
[Outreachy PATCH] prune-packed: remove use_the_repository_variable - #2266
Open
shashu8660 wants to merge 1 commit into
Open
shashu8660 wants to merge 1 commit into
shashu8660 wants to merge 1 commit into
Conversation
shashu8660
force-pushed
the
outreachy2
branch
from
October 18, 2026 10:43
e99ad44 to
9f3ff59
Compare
Author
|
/preview |
|
Preview email sent as pull.2266.git.1792320336845.gitgitgadget@gmail.com |
shashu8660
force-pushed
the
outreachy2
branch
from
October 18, 2026 10:53
9f3ff59 to
5d9ba0c
Compare
Author
|
/submit |
|
Submitted as pull.2266.git.1792341073005.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
|
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 |
|
User |
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
force-pushed
the
outreachy2
branch
from
October 19, 2026 16:44
5d9ba0c to
6b583e1
Compare
Author
|
/preview |
|
Preview email sent as pull.2266.v2.git.1792428445532.gitgitgadget@gmail.com |
Author
|
/submit |
|
Submitted as pull.2266.v2.git.1792428811100.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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