From: Junio C Hamano <gitster@pobox.com>
To: "John Cai via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, John Cai <johncai86@gmail.com>
Subject: Re: [PATCH 0/3] Add repository parameter to builtins
Date: Thu, 05 Sep 2024 10:21:04 -0700 [thread overview]
Message-ID: <xmqqjzfq2f0f.fsf@gitster.g> (raw)
In-Reply-To: <pull.1778.git.git.1725555467.gitgitgadget@gmail.com> (John Cai via GitGitGadget's message of "Thu, 05 Sep 2024 16:57:44 +0000")
"John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes:
> As part of the effort to remove global state of the_repository, add a
> repository parameter to builtins so that a repository variable can be passed
> down. The patches are ordered as follows:
>
> 1. Changes the signature of builtins and passes the_repository down in
> git.c to be called by all builtins.
> 2. Remove USE_THE_REPOSITORY_VARIABLE from builtin.h, and instead add it to
> each individual builtin. This paves the way for a migration process
> whereby each builtin can be migrated away from using the_repository.
> 3. As an example, migrate builtin/add.c to get rid of the_repository by
> instead passing the repository argument down into helper functions.
As most of the commands require a repository (as they should---those
that work without a repository ought to be outliners, things that
are needed to bootstrap like "git init" and "git clone", or those
that allow us to interact with a remote repository without having
any repository on our side to be affected, like "git archive" or
"git ls-remote"), I think this probably makes sense as a good first
step.
And there are commands that are primarily for working with Git, but
optionally can work outside a repository. They need to do special
things in any case by calling setup_git_directory_gently() with
nongit to figure out if they are in the repository, e.g.
prefix = setup_git_directory_gently(&nongit);
if (!nongit) {
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;
} else {
... do whatever it can outside a repository ...
}
(note: this was taken from "git diff" with a bit of tweak, but
others in the same category should look very similar), so I would
imagine that we may want to update setup_git_directory_gently() to
be more like:
const char *setup_git_directory_gently(struct repository **repo);
and the above snippet would become:
prefix = setup_git_directory_gently(&repo);
if (repo) {
prepare_repo_settings(repo);
repo->settings.command_requires_full_index = 0;
} else {
...
}
IOW, "nongit" Boolean flag we use to say "are we working without a
repository?" becomes "the dispatcher in git.c usually gives us the
repository in repo, but we asked them not to do the repository setup
and we will call setup_git_directory_gently() ourselves, allowing
the call to overwrite the repo parameter given."
Thanks.
next prev parent reply other threads:[~2024-09-05 17:21 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 16:57 [PATCH 0/3] Add repository parameter to builtins John Cai via GitGitGadget
2024-09-05 16:57 ` [PATCH 1/3] builtin: add a repository parameter for builtin functions John Cai via GitGitGadget
2024-09-06 10:46 ` Patrick Steinhardt
2024-09-09 21:08 ` John Cai
2024-09-05 16:57 ` [PATCH 2/3] builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h John Cai via GitGitGadget
2024-09-05 17:50 ` Junio C Hamano
2024-09-06 10:46 ` Patrick Steinhardt
2024-09-06 15:43 ` Junio C Hamano
2024-09-05 16:57 ` [PATCH 3/3] add: pass in repo variable instead of global the_repository John Cai via GitGitGadget
2024-09-06 10:46 ` Patrick Steinhardt
2024-09-05 17:21 ` Junio C Hamano [this message]
2024-09-10 20:59 ` [PATCH v2 0/3] Add repository parameter to builtins John Cai via GitGitGadget
2024-09-10 20:59 ` [PATCH v2 1/3] builtin: add a repository parameter for builtin functions John Cai via GitGitGadget
2024-09-10 21:40 ` Junio C Hamano
2024-09-11 21:08 ` Junio C Hamano
2024-09-12 9:45 ` Patrick Steinhardt
2024-09-12 10:43 ` Jeff King
2024-09-12 10:50 ` Jeff King
2024-09-12 10:55 ` Patrick Steinhardt
2024-09-13 17:54 ` John Cai
2024-09-10 20:59 ` [PATCH v2 2/3] builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h John Cai via GitGitGadget
2024-09-11 18:15 ` Junio C Hamano
2024-09-13 18:00 ` John Cai
2024-09-10 20:59 ` [PATCH v2 3/3] add: pass in repo variable instead of global the_repository John Cai via GitGitGadget
2024-09-11 18:23 ` Junio C Hamano
2024-09-13 21:16 ` [PATCH v3 0/4] Add repository parameter to builtins John Cai via GitGitGadget
2024-09-13 21:16 ` [PATCH v3 1/4] builtin: add a repository parameter for builtin functions John Cai via GitGitGadget
2024-09-13 21:16 ` [PATCH v3 2/4] builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h John Cai via GitGitGadget
2024-09-13 21:32 ` Junio C Hamano
2024-09-13 21:16 ` [PATCH v3 3/4] builtin: remove USE_THE_REPOSITORY for those without the_repository John Cai via GitGitGadget
2024-09-13 21:16 ` [PATCH v3 4/4] add: pass in repo variable instead of global the_repository John Cai via GitGitGadget
2024-09-13 21:35 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqjzfq2f0f.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johncai86@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).