Skip to content

Commit d4bf1d8

Browse files
derrickstoleegitster
authored andcommitted
multi-pack-index: verify missing pack
Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8e72a3c commit d4bf1d8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

midx.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,29 @@ void clear_midx_file(const char *object_dir)
926926

927927
static int verify_midx_error;
928928

929+
static void midx_report(const char *fmt, ...)
930+
{
931+
va_list ap;
932+
verify_midx_error = 1;
933+
va_start(ap, fmt);
934+
vfprintf(stderr, fmt, ap);
935+
fprintf(stderr, "\n");
936+
va_end(ap);
937+
}
938+
929939
int verify_midx_file(const char *object_dir)
930940
{
941+
uint32_t i;
931942
struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
932943
verify_midx_error = 0;
933944

934945
if (!m)
935946
return 0;
936947

948+
for (i = 0; i < m->num_packs; i++) {
949+
if (prepare_midx_pack(m, i))
950+
midx_report("failed to load pack in position %d", i);
951+
}
952+
937953
return verify_midx_error;
938954
}

t/t5319-multi-pack-index.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ test_expect_success 'verify packnames out of order' '
222222
"pack names out of order"
223223
'
224224

225+
test_expect_success 'verify packnames out of order' '
226+
corrupt_midx_and_verify $MIDX_BYTE_PACKNAME_ORDER "a" $objdir \
227+
"failed to load pack"
228+
'
229+
225230
test_expect_success 'repack removes multi-pack-index' '
226231
test_path_is_file $objdir/pack/multi-pack-index &&
227232
git repack -adf &&

0 commit comments

Comments
 (0)