Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/read-cache.c b/read-cache.c
index d191741f60..7bd12afb38 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2300,8 +2300,6 @@ static void set_new_index_sparsity(struct index_state *istate)
* If the index's repo exists, mark it sparse according to
* repo settings.
*/
- if (!istate->repo)
- return;
prepare_repo_settings(istate->repo);
if (!istate->repo->settings.command_requires_full_index &&
is_sparse_index_allowed(istate, 0))
@@ -2330,8 +2328,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
fd = open(path, O_RDONLY);
if (fd < 0) {
if (!must_exist && errno == ENOENT) {
- if (!istate->repo)
- istate->repo = the_repository;
set_new_index_sparsity(istate);
return 0;
}
@@ -2433,9 +2429,6 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
trace2_data_intmax("index", the_repository, "read/cache_nr",
istate->cache_nr);
- if (!istate->repo)
- istate->repo = the_repository;
-
/*
* If the command explicitly requires a full index, force it
* to be full. Otherwise, correct the sparsity based on repository
@@ -2501,7 +2494,7 @@ int read_index_from(struct index_state *istate, const char *path,
release_index(split_index->base);
else
ALLOC_ARRAY(split_index->base, 1);
- index_state_init(split_index->base);
+ index_state_init(split_index->base, istate->repo);
base_oid_hex = oid_to_hex(&split_index->base_oid);
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
@@ -2540,9 +2533,9 @@ int is_index_unborn(struct index_state *istate)
return (!istate->cache_nr && !istate->timestamp.sec);
}
-void index_state_init(struct index_state *istate)
+void index_state_init(struct index_state *istate, struct repository *r)
{
- struct index_state blank = INDEX_STATE_INIT;
+ struct index_state blank = INDEX_STATE_INIT(r);
memcpy(istate, &blank, sizeof(*istate));
}
@@ -2579,7 +2572,7 @@ void release_index(struct index_state *istate)
void discard_index(struct index_state *istate)
{
release_index(istate);
- index_state_init(istate);
+ index_state_init(istate, istate->repo);
}
/*
@@ -2933,7 +2926,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
int ieot_entries = 1;
struct index_entry_offset_table *ieot = NULL;
int nr, nr_threads;
- struct repository *r = istate->repo ? istate->repo : the_repository;
+ struct repository *r = istate->repo;
f = hashfd(tempfile->fd, tempfile->filename.buf);