summaryrefslogtreecommitdiff
path: root/pack-revindex.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2021-01-25 23:37:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-26 02:32:44 (GMT)
commitec8e7760ac38ef426f87ec738454e574be53a00e (patch)
tree03da0ca6bab1e384f5a2823705de6fa97f71938d /pack-revindex.c
parente8c58f894b4d5369779e06ff7dc03fb0706c930a (diff)
downloadgit-ec8e7760ac38ef426f87ec738454e574be53a00e.zip
git-ec8e7760ac38ef426f87ec738454e574be53a00e.tar.gz
git-ec8e7760ac38ef426f87ec738454e574be53a00e.tar.bz2
pack-revindex: ensure that on-disk reverse indexes are given precedence
When an on-disk reverse index exists, there is no need to generate one in memory. In fact, doing so can be slow, and require large amounts of the heap. Let's make sure that we treat the on-disk reverse index with precedence (i.e., that when it exists, we don't bother trying to generate an equivalent one in memory) by teaching Git how to conditionally die() when generating a reverse index in memory. Then, add a test to ensure that when (a) an on-disk reverse index exists, and (b) when setting GIT_TEST_REV_INDEX_DIE_IN_MEMORY, that we do not die, implying that we read from the on-disk one. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-revindex.c')
-rw-r--r--pack-revindex.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pack-revindex.c b/pack-revindex.c
index a174fa5..83fe4de 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -2,6 +2,7 @@
#include "pack-revindex.h"
#include "object-store.h"
#include "packfile.h"
+#include "config.h"
struct revindex_entry {
off_t offset;
@@ -166,6 +167,9 @@ static void create_pack_revindex(struct packed_git *p)
static int create_pack_revindex_in_memory(struct packed_git *p)
{
+ if (git_env_bool(GIT_TEST_REV_INDEX_DIE_IN_MEMORY, 0))
+ die("dying as requested by '%s'",
+ GIT_TEST_REV_INDEX_DIE_IN_MEMORY);
if (open_pack_index(p))
return -1;
create_pack_revindex(p);