summaryrefslogtreecommitdiff
path: root/split-index.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-06-13 12:19:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-13 18:49:41 (GMT)
commitc18b80a0e86c4529146e3947454159627f1419a7 (patch)
treeaad268bd7feaf75d694b902deb139e3aaf77da2e /split-index.c
parentb3c96fb158f05152336f167076f5d81d23c3a5e5 (diff)
downloadgit-c18b80a0e86c4529146e3947454159627f1419a7.zip
git-c18b80a0e86c4529146e3947454159627f1419a7.tar.gz
git-c18b80a0e86c4529146e3947454159627f1419a7.tar.bz2
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>
Diffstat (limited to 'split-index.c')
-rw-r--r--split-index.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/split-index.c b/split-index.c
index ee3246f..21485e2 100644
--- a/split-index.c
+++ b/split-index.c
@@ -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;