update-index: new options to enable/disable split index mode
If you have a large work tree but only make changes in a subset, then $GIT_DIR/index's size should be stable after a while. If you change branches that touch something else, $GIT_DIR/index's size may grow large that it becomes as slow as the unified index. Do --split-index again occasionally to force all changes back to the shared index and keep $GIT_DIR/index small. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b3c96fb158
commit
c18b80a0e8
@ -74,6 +74,29 @@ static void mark_base_index_entries(struct index_state *base)
|
||||
base->cache[i]->index = i + 1;
|
||||
}
|
||||
|
||||
void move_cache_to_base_index(struct index_state *istate)
|
||||
{
|
||||
struct split_index *si = istate->split_index;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* do not delete old si->base, its index entries may be shared
|
||||
* with istate->cache[]. Accept a bit of leaking here because
|
||||
* this code is only used by short-lived update-index.
|
||||
*/
|
||||
si->base = xcalloc(1, sizeof(*si->base));
|
||||
si->base->version = istate->version;
|
||||
/* zero timestamp disables racy test in ce_write_index() */
|
||||
si->base->timestamp = istate->timestamp;
|
||||
ALLOC_GROW(si->base->cache, istate->cache_nr, si->base->cache_alloc);
|
||||
si->base->cache_nr = istate->cache_nr;
|
||||
memcpy(si->base->cache, istate->cache,
|
||||
sizeof(*istate->cache) * istate->cache_nr);
|
||||
mark_base_index_entries(si->base);
|
||||
for (i = 0; i < si->base->cache_nr; i++)
|
||||
si->base->cache[i]->ce_flags &= ~CE_UPDATE_IN_BASE;
|
||||
}
|
||||
|
||||
static void mark_entry_for_delete(size_t pos, void *data)
|
||||
{
|
||||
struct index_state *istate = data;
|
||||
|
||||
Reference in New Issue
Block a user