diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-02-18 13:53:30 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-18 13:53:30 -0800 |
commit | 9b7e531f94c610439cff3c8d4556742524184463 (patch) | |
tree | 13c7e3ade31359f53e48c5353debbd4b6bea6753 /midx.c | |
parent | 18636afdce5f272d79fe6c3036e4e74f69a0845a (diff) | |
parent | eb57277ba3dcdf97a66dcd2c471e29bf64d3279f (diff) | |
download | git-9b7e531f94c610439cff3c8d4556742524184463.tar.gz |
Merge branch 'tb/midx-no-bitmap-for-no-objects'
When there is no object to write .bitmap file for, "git
multi-pack-index" triggered an error, instead of just skipping,
which has been corrected.
* tb/midx-no-bitmap-for-no-objects:
midx: prevent writing a .bitmap without any objects
Diffstat (limited to 'midx.c')
-rw-r--r-- | midx.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -1077,6 +1077,9 @@ static int write_midx_bitmap(char *midx_name, unsigned char *midx_hash, char *bitmap_name = xstrfmt("%s-%s.bitmap", midx_name, hash_to_hex(midx_hash)); int ret; + if (!ctx->entries_nr) + BUG("cannot write a bitmap without any objects"); + if (flags & MIDX_WRITE_BITMAP_HASH_CACHE) options |= BITMAP_OPT_HASH_CACHE; @@ -1401,6 +1404,12 @@ static int write_midx_internal(const char *object_dir, goto cleanup; } + if (!ctx.entries_nr) { + if (flags & MIDX_WRITE_BITMAP) + warning(_("refusing to write multi-pack .bitmap without any objects")); + flags &= ~(MIDX_WRITE_REV_INDEX | MIDX_WRITE_BITMAP); + } + cf = init_chunkfile(f); add_chunk(cf, MIDX_CHUNKID_PACKNAMES, pack_name_concat_len, |