Skip to content

Commit d6e3c18

Browse files
pcloudsgitster
authored andcommitted
read-cache: force split index mode with GIT_TEST_SPLIT_INDEX
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5a092ce commit d6e3c18

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

read-cache.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,8 +1885,11 @@ static int do_write_index(struct index_state *istate, int newfd,
18851885
}
18861886
}
18871887

1888-
if (!istate->version)
1888+
if (!istate->version) {
18891889
istate->version = get_index_format_default();
1890+
if (getenv("GIT_TEST_SPLIT_INDEX"))
1891+
init_split_index(istate);
1892+
}
18901893

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

2083+
if (getenv("GIT_TEST_SPLIT_INDEX")) {
2084+
int v = si->base_sha1[0];
2085+
if ((v & 15) < 6)
2086+
istate->cache_changed |= SPLIT_INDEX_ORDERED;
2087+
}
20802088
if (istate->cache_changed & SPLIT_INDEX_ORDERED) {
20812089
int ret = write_shared_index(istate, lock, flags);
20822090
if (ret)

0 commit comments

Comments
 (0)