summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pack-revindex.c4
-rw-r--r--pack-revindex.h1
-rwxr-xr-xt/t5325-reverse-index.sh9
3 files changed, 14 insertions, 0 deletions
diff --git a/pack-revindex.c b/pack-revindex.c
index a174fa5388..83fe4de773 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);
diff --git a/pack-revindex.h b/pack-revindex.h
index d1a0595e89..ba7c82c125 100644
--- a/pack-revindex.h
+++ b/pack-revindex.h
@@ -21,6 +21,7 @@
#define RIDX_VERSION 1
#define GIT_TEST_WRITE_REV_INDEX "GIT_TEST_WRITE_REV_INDEX"
+#define GIT_TEST_REV_INDEX_DIE_IN_MEMORY "GIT_TEST_REV_INDEX_DIE_IN_MEMORY"
struct packed_git;
diff --git a/t/t5325-reverse-index.sh b/t/t5325-reverse-index.sh
index be452bb343..a344b18d7e 100755
--- a/t/t5325-reverse-index.sh
+++ b/t/t5325-reverse-index.sh
@@ -85,4 +85,13 @@ test_expect_success 'pack-objects respects pack.writeReverseIndex' '
test_path_is_file pack-1-*.rev
'
+test_expect_success 'reverse index is not generated when available on disk' '
+ test_index_pack true &&
+ test_path_is_file $rev &&
+
+ git rev-parse HEAD >tip &&
+ GIT_TEST_REV_INDEX_DIE_IN_MEMORY=1 git cat-file \
+ --batch-check="%(objectsize:disk)" <tip
+'
+
test_done