split-index: add {add,remove}_split_index() functions
Also use the functions in cmd_update_index() in builtin/update-index.c. These functions will be used in a following commit to tweak our use of the split-index feature depending on the setting of a configuration variable. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
1f44b09b58
commit
cef4fc7ebe
@@ -1099,18 +1099,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (split_index > 0) {
|
if (split_index > 0) {
|
||||||
init_split_index(&the_index);
|
if (the_index.split_index)
|
||||||
the_index.cache_changed |= SPLIT_INDEX_ORDERED;
|
the_index.cache_changed |= SPLIT_INDEX_ORDERED;
|
||||||
} else if (!split_index && the_index.split_index) {
|
else
|
||||||
/*
|
add_split_index(&the_index);
|
||||||
* can't discard_split_index(&the_index); because that
|
} else if (!split_index)
|
||||||
* will destroy split_index->base->cache[], which may
|
remove_split_index(&the_index);
|
||||||
* be shared with the_index.cache[]. So yeah we're
|
|
||||||
* leaking a bit here.
|
|
||||||
*/
|
|
||||||
the_index.split_index = NULL;
|
|
||||||
the_index.cache_changed |= SOMETHING_CHANGED;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (untracked_cache) {
|
switch (untracked_cache) {
|
||||||
case UC_UNSPECIFIED:
|
case UC_UNSPECIFIED:
|
||||||
|
|||||||
@@ -317,3 +317,25 @@ void replace_index_entry_in_base(struct index_state *istate,
|
|||||||
istate->split_index->base->cache[new->index - 1] = new;
|
istate->split_index->base->cache[new->index - 1] = new;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_split_index(struct index_state *istate)
|
||||||
|
{
|
||||||
|
if (!istate->split_index) {
|
||||||
|
init_split_index(istate);
|
||||||
|
istate->cache_changed |= SPLIT_INDEX_ORDERED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_split_index(struct index_state *istate)
|
||||||
|
{
|
||||||
|
if (istate->split_index) {
|
||||||
|
/*
|
||||||
|
* can't discard_split_index(&the_index); because that
|
||||||
|
* will destroy split_index->base->cache[], which may
|
||||||
|
* be shared with the_index.cache[]. So yeah we're
|
||||||
|
* leaking a bit here.
|
||||||
|
*/
|
||||||
|
istate->split_index = NULL;
|
||||||
|
istate->cache_changed |= SOMETHING_CHANGED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,5 +31,7 @@ void merge_base_index(struct index_state *istate);
|
|||||||
void prepare_to_write_split_index(struct index_state *istate);
|
void prepare_to_write_split_index(struct index_state *istate);
|
||||||
void finish_writing_split_index(struct index_state *istate);
|
void finish_writing_split_index(struct index_state *istate);
|
||||||
void discard_split_index(struct index_state *istate);
|
void discard_split_index(struct index_state *istate);
|
||||||
|
void add_split_index(struct index_state *istate);
|
||||||
|
void remove_split_index(struct index_state *istate);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user