pack-revindex: introduce GIT_TEST_REV_INDEX_DIE_ON_DISK

In ec8e7760ac (pack-revindex: ensure that on-disk reverse indexes are given precedence, 2021-01-25), we introduced GIT_TEST_REV_INDEX_DIE_IN_MEMORY to abort the process when Git generated a reverse index from scratch. ec8e7760ac was about ensuring that Git prefers a .rev file when available over generating the same information in memory from scratch. In a subsequent patch, we'll introduce `pack.readReverseIndex`, which may be used to disable reading ".rev" files when available. In order to ensure that those files are indeed being ignored, introduce an analogous option to abort the process when Git reads a ".rev" file from disk. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Apr 12, 2023 at 18:20 UTC 2a250d6165deee97dd7d8641096b93b85fa95287
2 files changed +4
pack-revindex.c
+3
@@ -205,6 +205,9 @@ static int load_revindex_from_disk(char *revindex_name,
205 size_t revindex_size;
206 struct revindex_header *hdr;
207
208 + if (git_env_bool(GIT_TEST_REV_INDEX_DIE_ON_DISK, 0))
209 + die("dying as requested by '%s'", GIT_TEST_REV_INDEX_DIE_ON_DISK);
210 +
211 fd = git_open(revindex_name);
212
213 if (fd < 0) {
pack-revindex.h
+1
@@ -36,6 +36,7 @@
36
37 #define GIT_TEST_WRITE_REV_INDEX "GIT_TEST_WRITE_REV_INDEX"
38 #define GIT_TEST_REV_INDEX_DIE_IN_MEMORY "GIT_TEST_REV_INDEX_DIE_IN_MEMORY"
39 +#define GIT_TEST_REV_INDEX_DIE_ON_DISK "GIT_TEST_REV_INDEX_DIE_ON_DISK"
40
41 struct packed_git;
42 struct multi_pack_index;