diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-04-18 14:14:19 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-04-18 21:30:42 +0200 |
commit | 66bce9d00bc4e2f89b2aea21d1e162c9ee47f55c (patch) | |
tree | f65575790cf30e53805be728d52c98c35cf72bf9 /builtin | |
parent | builtin: stop using `the_index` (diff) | |
download | git-66bce9d00bc4e2f89b2aea21d1e162c9ee47f55c.tar.xz git-66bce9d00bc4e2f89b2aea21d1e162c9ee47f55c.zip |
repository: initialize index in `repo_init()`
When Git starts, one of the first things it will do is to call
`initialize_the_repository()`. This function sets up both the global
`the_repository` and `the_index` variables as required. Part of that
setup is also to set `the_repository.index = &the_index` so that the
index can be accessed via the repository.
When calling `repo_init()` on a repository though we set the complete
struct to all-zeroes, which will also cause us to unset the `index`
pointer. And as we don't re-initialize the index in that function, we
will end up with a `NULL` pointer here.
This has been fine until now becaues this function is only used to
create a new repository. git-init(1) does not access the index at all
after initializing the repository, whereas git-checkout(1) only uses
`the_index` directly. We are about to remove `the_index` though, which
will uncover this partially-initialized repository structure.
Refactor the code and create a common `initialize_repository()` function
that gets called from `repo_init()` and `initialize_the_repository()`.
This function sets up both the repository and the index as required.
Like this, we can easily special-case when `repo_init()` gets called
with `the_repository`.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
0 files changed, 0 insertions, 0 deletions