Skip to content

Commit

Permalink
read-cache: force split index mode with GIT_TEST_SPLIT_INDEX
Browse files Browse the repository at this point in the history
This could be used to run the whole test suite with split
indexes. Index splitting is carried out at random. "git read-tree"
also resets the index and forces splitting at the next update.

I had a lot of headaches with the test suite, which proves it
exercises split index pretty good.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Jun 13, 2014
1 parent 5a092ce commit d6e3c18
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1885,8 +1885,11 @@ static int do_write_index(struct index_state *istate, int newfd,
}
}

if (!istate->version)
if (!istate->version) {
istate->version = get_index_format_default();
if (getenv("GIT_TEST_SPLIT_INDEX"))
init_split_index(istate);
}

/* demote version 3 to version 2 when the latter suffices */
if (istate->version == 3 || istate->version == 2)
Expand Down Expand Up @@ -2077,6 +2080,11 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
return do_write_locked_index(istate, lock, flags);
}

if (getenv("GIT_TEST_SPLIT_INDEX")) {
int v = si->base_sha1[0];
if ((v & 15) < 6)
istate->cache_changed |= SPLIT_INDEX_ORDERED;
}
if (istate->cache_changed & SPLIT_INDEX_ORDERED) {
int ret = write_shared_index(istate, lock, flags);
if (ret)
Expand Down

0 comments on commit d6e3c18

Please sign in to comment.