|
1 |
| -/* |
2 |
| - * not really _using_ the compat macros, just make sure the_index |
3 |
| - * declaration matches the definition in this file. |
4 |
| - */ |
5 |
| -#define USE_THE_INDEX_VARIABLE |
6 | 1 | #include "git-compat-util.h"
|
7 | 2 | #include "abspath.h"
|
8 | 3 | #include "repository.h"
|
|
23 | 18 | /* The main repository */
|
24 | 19 | static struct repository the_repo;
|
25 | 20 | struct repository *the_repository;
|
26 |
| -struct index_state the_index; |
27 | 21 |
|
28 |
| -static void initialize_repository(struct repository *repo, |
29 |
| - struct index_state *index) |
| 22 | +static void initialize_repository(struct repository *repo) |
30 | 23 | {
|
31 |
| - repo->index = index; |
32 | 24 | repo->objects = raw_object_store_new();
|
33 | 25 | repo->remote_state = remote_state_new();
|
34 | 26 | repo->parsed_objects = parsed_object_pool_new();
|
35 |
| - index_state_init(index, repo); |
| 27 | + ALLOC_ARRAY(repo->index, 1); |
| 28 | + index_state_init(repo->index, repo); |
36 | 29 | }
|
37 | 30 |
|
38 | 31 | void initialize_the_repository(void)
|
39 | 32 | {
|
40 | 33 | the_repository = &the_repo;
|
41 |
| - initialize_repository(the_repository, &the_index); |
| 34 | + initialize_repository(the_repository); |
42 | 35 | repo_set_hash_algo(&the_repo, GIT_HASH_SHA1);
|
43 | 36 | }
|
44 | 37 |
|
@@ -191,12 +184,7 @@ int repo_init(struct repository *repo,
|
191 | 184 | struct repository_format format = REPOSITORY_FORMAT_INIT;
|
192 | 185 | memset(repo, 0, sizeof(*repo));
|
193 | 186 |
|
194 |
| - if (repo == the_repository) { |
195 |
| - initialize_repository(the_repository, &the_index); |
196 |
| - } else { |
197 |
| - ALLOC_ARRAY(repo->index, 1); |
198 |
| - initialize_repository(repo, repo->index); |
199 |
| - } |
| 187 | + initialize_repository(repo); |
200 | 188 |
|
201 | 189 | if (repo_init_gitdir(repo, gitdir))
|
202 | 190 | goto error;
|
@@ -313,8 +301,7 @@ void repo_clear(struct repository *repo)
|
313 | 301 |
|
314 | 302 | if (repo->index) {
|
315 | 303 | discard_index(repo->index);
|
316 |
| - if (repo->index != &the_index) |
317 |
| - FREE_AND_NULL(repo->index); |
| 304 | + FREE_AND_NULL(repo->index); |
318 | 305 | }
|
319 | 306 |
|
320 | 307 | if (repo->promisor_remote_config) {
|
|
0 commit comments