diff options
| author | Han-Wen Nienhuys <hanwen@google.com> | 2022-02-21 18:46:07 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-02-23 13:36:26 -0800 |
| commit | 45c2fcc2a0659e42c7e4f21f0b97393df261ca51 (patch) | |
| tree | 310a0c84d44b04f2c04580588c51246d3a239df3 /reftable/block_test.c | |
| parent | 140765911050d62a23503972ef6513ef18252ad3 (diff) | |
| download | git-45c2fcc2a0659e42c7e4f21f0b97393df261ca51.tar.xz | |
reftable: avoid writing empty keys at the block layer
The public interface (reftable_writer) already ensures that keys are
written in strictly increasing order, and an empty key by definition
fails this check.
However, by also enforcing this at the block layer, it is easier to
verify that records (which are written into blocks) never have to
consider the possibility of empty keys.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/block_test.c')
| -rw-r--r-- | reftable/block_test.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/reftable/block_test.c b/reftable/block_test.c index fa2ee092ec..cb88af4a56 100644 --- a/reftable/block_test.c +++ b/reftable/block_test.c @@ -42,6 +42,11 @@ static void test_block_read_write(void) block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size, header_off, hash_size(GIT_SHA1_FORMAT_ID)); + rec.u.ref.refname = ""; + rec.u.ref.value_type = REFTABLE_REF_DELETION; + n = block_writer_add(&bw, &rec); + EXPECT(n == REFTABLE_API_ERROR); + for (i = 0; i < N; i++) { char name[100]; uint8_t hash[GIT_SHA1_RAWSZ]; |
