Subject: Re: [PATCH v2 1/3] builtin: add a repository parameter for builtin functions

From: Junio C Hamano <[email-masked]>
Date: Wed, 11 Sep 2024 14:08:17 -0700

Junio C Hamano <[email-masked]> writes:

> "John Cai via GitGitGadget" <[email-masked]> writes:
>
>>  git.c                              |  12 +-
>>  help.c                             |   3 +-
>>  stkOs5Qh                           | Bin 0 -> 10485768 bytes
>
> WTH is this file?

It turns out to be an "ar" archive full of *.o files.  Perhaps
creation of libgit.a was interrupted, then later somebody said
"git add .", and the file somehow ended up as a part of Git.

I've applied the series after removing the cruft.

The overall thrust to pass the repository found by the setup step to
builtins as a parameter is a very good one, as most of the Git
commands are designed to work in a repository.

With this, can commands that are marked with RUN_SETUP_GENTLY rely
on the NULL-ness of repo parameter to decide if they are in a
repository or running outside a repository?

The "nongit?" status returned from setup_git_directory_gently() call
made by git.c:run_builtin() is thrown away and not passed to the
builtin functions at all, so some of them currently may be doing
another discovery themselves, and if we can replace such a wasteful
setup_git_directory_gently() call, it would be nice, and passing the
discovered repository instance to builtin commands is a good first
step to go there.

Thanks.