]> git.ipfire.org Git - thirdparty/git.git/commit
reftable: stop using `strbuf_addf()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 17 Oct 2024 04:53:47 +0000 (06:53 +0200)
committerTaylor Blau <me@ttaylorr.com>
Thu, 17 Oct 2024 20:59:55 +0000 (16:59 -0400)
commit7fa7e14ebee9d82545bb4a8dcc1cac22ef51cfed
tree324fe59913e00241fd7560cbcbd4be39a4efa769
parent409f04995e6ede838576fb795cf45dc6f10ab508
reftable: stop using `strbuf_addf()`

We're about to introduce our own `reftable_buf` type to replace
`strbuf`. One function we'll have to convert is `strbuf_addf()`, which
is used in a handful of places. This function uses `snprintf()`
internally, which makes porting it a bit more involved:

  - It is not available on all platforms.

  - Some platforms like Windows have broken implementations.

So by using `snprintf()` we'd also push the burden on downstream users
of the reftable library to make available a properly working version of
it.

Most callsites of `strbuf_addf()` are trivial to convert to not using
it. We do end up using `snprintf()` in our unit tests, but that isn't
much of a problem for downstream users of the reftable library.

While at it, remove a useless call to `strbuf_reset()` in
`t_reftable_stack_auto_compaction_with_locked_tables()`. We don't write
to the buffer before this and initialize it with `STRBUF_INIT`, so there
is no need to reset anything.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
reftable/stack.c
t/unit-tests/t-reftable-block.c
t/unit-tests/t-reftable-readwrite.c
t/unit-tests/t-reftable-stack.c