mbox series

[0/7,Outreachy] stop using the_repository global variable.

Message ID 20250214230210.1460111-1-usmanakinyemi202@gmail.com (mailing list archive)
Headers show
Series stop using the_repository global variable. | expand

Message

Usman Akinyemi Feb. 14, 2025, 10:57 p.m. UTC
Remove `the_repository` global variable in favor of the repository
argument that gets passed in builtin commands. 

These sets of commands are commands that use only RUN_SETUP macro in "git.c".
Basically, When `-h` is passed to any of this command outside a Git repository,
the `run_builtin()` will call the `cmd_x()` function (where `x` is any
of the command from the sets of builtin commands that `the_repository` is removed
from) with `repo` set to NULL and then early in the function, `parse_options()`
or show_usage_with_options_if_asked() call will give the options help and exit,
without having to consult much of the configuration file.

As there exist some builtin commands where the `repository` variable is accessed
before options is given exit and fail, we should check if the `repository` variable
is not NULL in such scenerio.

Some, functions also uses `the_repository` global internally, so, let's
let's refactor them and pass `struct repo` as one of the argument. 

I picked some of this files based on the above explanation, how easy they are to
resolve and how easy easy to review. 

[1]: https://public-inbox.org/git/20250210181103.3609495-1-usmanakinyemi202@gmail.com/
*** BLURB HERE ***

Usman Akinyemi (7):
  builtin/verify-tag: stop using `the_repository`
  builtin/verify-commit.c: stop using `the_repository`
  builtin/send-pack.c: stop using `the_repository`
  builtin/pack-refs: stop using `the_repository`
  builtin/ls-files: stop using `the_repository`
  builtin/for-each-ref: stop using `the_repository`
  builtin/checkout-index.c: stop using `the_repository`

 builtin/checkout-index.c | 43 ++++++++++++++++++++--------------------
 builtin/for-each-ref.c   |  6 +++---
 builtin/ls-files.c       | 32 +++++++++++++++---------------
 builtin/pack-refs.c      |  9 ++++-----
 builtin/send-pack.c      |  8 ++++----
 builtin/verify-commit.c  | 14 ++++++-------
 builtin/verify-tag.c     |  8 ++++----
 7 files changed, 59 insertions(+), 61 deletions(-)

Comments

shejialuo Feb. 16, 2025, 5:41 a.m. UTC | #1
On Sat, Feb 15, 2025 at 04:27:16AM +0530, Usman Akinyemi wrote:

[snip]

> Usman Akinyemi (7):
>   builtin/verify-tag: stop using `the_repository`
>   builtin/verify-commit.c: stop using `the_repository`
>   builtin/send-pack.c: stop using `the_repository`
>   builtin/pack-refs: stop using `the_repository`
>   builtin/ls-files: stop using `the_repository`
>   builtin/for-each-ref: stop using `the_repository`
>   builtin/checkout-index.c: stop using `the_repository`
> 

The commit message is not consistent. We should remove ".c".
Usman Akinyemi Feb. 17, 2025, 8:56 a.m. UTC | #2
On Sun, Feb 16, 2025 at 11:11 AM shejialuo <shejialuo@gmail.com> wrote:
>
> On Sat, Feb 15, 2025 at 04:27:16AM +0530, Usman Akinyemi wrote:
>
> [snip]
>
> > Usman Akinyemi (7):
> >   builtin/verify-tag: stop using `the_repository`
> >   builtin/verify-commit.c: stop using `the_repository`
> >   builtin/send-pack.c: stop using `the_repository`
> >   builtin/pack-refs: stop using `the_repository`
> >   builtin/ls-files: stop using `the_repository`
> >   builtin/for-each-ref: stop using `the_repository`
> >   builtin/checkout-index.c: stop using `the_repository`
> >
>
> The commit message is not consistent. We should remove ".c".
Yeah, I will fix it in the next version.