All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: Edward Thomson <ethomson@edwardthomson.com>,
	karthik nayak <karthik.188@gmail.com>,
	Taylor Blau <me@ttaylorr.com>, shejialuo <shejialuo@gmail.com>
Subject: [PATCH v3 00/10] reftable: stop using `struct strbuf`
Date: Thu, 17 Oct 2024 06:53:42 +0200	[thread overview]
Message-ID: <cover.1729140565.git.ps@pks.im> (raw)
In-Reply-To: <cover.1728629612.git.ps@pks.im>

Hi,

this is the third version of my patch series that removes use of `struct
strbuf` in the reftable library. The intent of this is to convert the
reftable library back into a standalone library that can be used in the
context of libgit2.

Changes compared to v2:

  - Provide more context around why we get rid of `stbuf_addf()`.

  - Fix a commit message type.

  - Provide better docs for `reftable_buf_add()`.

Thanks!

Patrick

Patrick Steinhardt (10):
  reftable: stop using `strbuf_addbuf()`
  reftable: stop using `strbuf_addf()`
  reftable/basics: provide new `reftable_buf` interface
  reftable: convert from `strbuf` to `reftable_buf`
  reftable/blocksource: adapt interface name
  t/unit-tests: check for `reftable_buf` allocation errors
  reftable/stack: adapt `format_name()` to handle allocation failures
  reftable/record: adapt `reftable_record_key()` to handle allocation
    failures
  reftable/stack: adapt `stack_filename()` to handle allocation failures
  reftable: handle trivial `reftable_buf` errors

 reftable/basics.c                   |  76 +++++++++-
 reftable/basics.h                   |  61 +++++++-
 reftable/block.c                    |  61 +++++---
 reftable/block.h                    |  14 +-
 reftable/blocksource.c              |  30 ++--
 reftable/blocksource.h              |   5 +-
 reftable/iter.c                     |   9 +-
 reftable/iter.h                     |   8 +-
 reftable/reader.c                   |  27 ++--
 reftable/record.c                   | 114 ++++++++------
 reftable/record.h                   |  21 +--
 reftable/stack.c                    | 221 ++++++++++++++++++----------
 reftable/system.h                   |   1 -
 reftable/writer.c                   | 102 ++++++++-----
 reftable/writer.h                   |   2 +-
 t/unit-tests/lib-reftable.c         |   4 +-
 t/unit-tests/lib-reftable.h         |   7 +-
 t/unit-tests/t-reftable-basics.c    |  16 +-
 t/unit-tests/t-reftable-block.c     |  53 +++----
 t/unit-tests/t-reftable-merged.c    |  32 ++--
 t/unit-tests/t-reftable-reader.c    |  12 +-
 t/unit-tests/t-reftable-readwrite.c | 134 +++++++++--------
 t/unit-tests/t-reftable-record.c    |  74 +++++-----
 t/unit-tests/t-reftable-stack.c     |  96 ++++++------
 24 files changed, 728 insertions(+), 452 deletions(-)

Range-diff against v2:
 1:  7408482c152 =  1:  7408482c152 reftable: stop using `strbuf_addbuf()`
 2:  6a7333b275e !  2:  634fd3c35f5 reftable: stop using `strbuf_addf()`
    @@ Commit message
         reftable: stop using `strbuf_addf()`
     
         We're about to introduce our own `reftable_buf` type to replace
    -    `strbuf`. Get rid of the seldomly-used `strbuf_addf()` function such
    -    that we have to reimplement one less function.
    +    `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
 3:  0ddc8c0c896 !  3:  53c5f667f28 reftable/basics: provide new `reftable_buf` interface
    @@ Commit message
             to make things work, which is not all that sensible.
     
           - The `strbuf` interface does not use the pluggable allocators that
    -        can be set up via `refatble_set_alloc()`.
    +        can be set up via `reftable_set_alloc()`.
     
         So we have good reasons to use our own type, and the implementation is
         rather trivial. Implement our own type. Conversion of the reftable
 4:  e1ff1af1f30 !  4:  7c7ccc5d966 reftable: convert from `strbuf` to `reftable_buf`
    @@ reftable/basics.c: int names_equal(const char **a, const char **b)
      	for (; p < a->len && p < b->len; p++) {
     
      ## reftable/basics.h ##
    +@@ reftable/basics.h: int reftable_buf_setlen(struct reftable_buf *buf, size_t len);
    + int reftable_buf_cmp(const struct reftable_buf *a, const struct reftable_buf *b);
    + 
    + /*
    +- * Add the given bytes to the buffer. Returns 0 on success,
    ++ * Append `len` bytes from `data` to the buffer. This function works with
    ++ * arbitrary byte sequences, including ones that contain embedded NUL
    ++ * characters. As such, we use `void *` as input type. Returns 0 on success,
    +  * REFTABLE_OUT_OF_MEMORY_ERROR on allocation failure.
    +  */
    + int reftable_buf_add(struct reftable_buf *buf, const void *data, size_t len);
     @@ reftable/basics.h: char *reftable_strdup(const char *str);
      #endif
      
 5:  fe8c9ace463 =  5:  f9632860933 reftable/blocksource: adapt interface name
 6:  8c98745233a =  6:  d850a2fe7d0 t/unit-tests: check for `reftable_buf` allocation errors
 7:  1f08163009b =  7:  8f8e2ca3962 reftable/stack: adapt `format_name()` to handle allocation failures
 8:  5798d76d7a4 =  8:  268e4cd6fc6 reftable/record: adapt `reftable_record_key()` to handle allocation failures
 9:  a9582d51dd1 =  9:  245a428842a reftable/stack: adapt `stack_filename()` to handle allocation failures
10:  90819c90f38 = 10:  4b51ea4b628 reftable: handle trivial `reftable_buf` errors
-- 
2.47.0.72.gef8ce8f3d4.dirty


  parent reply	other threads:[~2024-10-17  4:53 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11  6:54 [PATCH 00/10] reftable: stop using `struct strbuf` Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 01/10] reftable: stop using `strbuf_addbuf()` Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 02/10] reftable: stop using `strbuf_addf()` Patrick Steinhardt
2024-10-11  9:51   ` karthik nayak
2024-10-14 13:09     ` Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 03/10] reftable/basics: provide new `reftable_buf` interface Patrick Steinhardt
2024-10-11 10:03   ` karthik nayak
2024-10-14 13:09     ` Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 04/10] reftable: convert from `strbuf` to `reftable_buf` Patrick Steinhardt
2024-10-11 12:12   ` karthik nayak
2024-10-14 13:09     ` Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 05/10] reftable/blocksource: adapt interface name Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 06/10] t/unit-tests: check for `reftable_buf` allocation errors Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 07/10] reftable/stack: adapt `format_name()` to handle allocation failures Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 08/10] reftable/record: adapt `reftable_record_key()` " Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 09/10] reftable/stack: adapt `stack_filename()` " Patrick Steinhardt
2024-10-11  6:54 ` [PATCH 10/10] reftable: handle trivial `reftable_buf` errors Patrick Steinhardt
2024-10-11 12:18 ` [PATCH 00/10] reftable: stop using `struct strbuf` karthik nayak
2024-10-14 13:09   ` Patrick Steinhardt
2024-10-14 13:02 ` [PATCH v2 " Patrick Steinhardt
2024-10-14 13:02   ` [PATCH v2 01/10] reftable: stop using `strbuf_addbuf()` Patrick Steinhardt
2024-10-14 22:19     ` Taylor Blau
2024-10-14 13:02   ` [PATCH v2 02/10] reftable: stop using `strbuf_addf()` Patrick Steinhardt
2024-10-14 22:32     ` Taylor Blau
2024-10-15  4:37       ` Patrick Steinhardt
2024-10-15 19:26         ` Taylor Blau
2024-10-14 13:02   ` [PATCH v2 03/10] reftable/basics: provide new `reftable_buf` interface Patrick Steinhardt
2024-10-14 22:34     ` Taylor Blau
2024-10-15  4:38       ` Patrick Steinhardt
2024-10-15  5:10         ` Eric Sunshine
2024-10-15 19:27           ` Taylor Blau
2024-10-16  8:42             ` Patrick Steinhardt
2024-10-16 20:56               ` Taylor Blau
2024-10-17  4:54                 ` Patrick Steinhardt
2024-10-17 20:59                   ` Taylor Blau
2024-10-14 13:02   ` [PATCH v2 04/10] reftable: convert from `strbuf` to `reftable_buf` Patrick Steinhardt
2024-10-14 22:35     ` Taylor Blau
2024-10-14 13:02   ` [PATCH v2 05/10] reftable/blocksource: adapt interface name Patrick Steinhardt
2024-10-14 13:02   ` [PATCH v2 06/10] t/unit-tests: check for `reftable_buf` allocation errors Patrick Steinhardt
2024-10-14 13:02   ` [PATCH v2 07/10] reftable/stack: adapt `format_name()` to handle allocation failures Patrick Steinhardt
2024-10-14 22:41     ` Taylor Blau
2024-10-14 13:02   ` [PATCH v2 08/10] reftable/record: adapt `reftable_record_key()` " Patrick Steinhardt
2024-10-14 13:02   ` [PATCH v2 09/10] reftable/stack: adapt `stack_filename()` " Patrick Steinhardt
2024-10-14 13:02   ` [PATCH v2 10/10] reftable: handle trivial `reftable_buf` errors Patrick Steinhardt
2024-10-14 22:44   ` [PATCH v2 00/10] reftable: stop using `struct strbuf` Taylor Blau
2024-10-15  4:37     ` Patrick Steinhardt
2024-10-15 10:33       ` shejialuo
2024-10-15 10:44         ` Patrick Steinhardt
2024-10-15 11:23           ` shejialuo
2024-10-17  4:53 ` Patrick Steinhardt [this message]
2024-10-17  4:53   ` [PATCH v3 01/10] reftable: stop using `strbuf_addbuf()` Patrick Steinhardt
2024-10-17  4:53   ` [PATCH v3 02/10] reftable: stop using `strbuf_addf()` Patrick Steinhardt
2024-10-17  4:53   ` [PATCH v3 03/10] reftable/basics: provide new `reftable_buf` interface Patrick Steinhardt
2024-10-17  4:53   ` [PATCH v3 04/10] reftable: convert from `strbuf` to `reftable_buf` Patrick Steinhardt
2024-10-17  4:53   ` [PATCH v3 05/10] reftable/blocksource: adapt interface name Patrick Steinhardt
2024-10-17  4:54   ` [PATCH v3 06/10] t/unit-tests: check for `reftable_buf` allocation errors Patrick Steinhardt
2024-10-17  4:54   ` [PATCH v3 07/10] reftable/stack: adapt `format_name()` to handle allocation failures Patrick Steinhardt
2024-10-17  4:54   ` [PATCH v3 08/10] reftable/record: adapt `reftable_record_key()` " Patrick Steinhardt
2024-10-17  4:54   ` [PATCH v3 09/10] reftable/stack: adapt `stack_filename()` " Patrick Steinhardt
2024-10-17  4:54   ` [PATCH v3 10/10] reftable: handle trivial `reftable_buf` errors Patrick Steinhardt
2024-10-17 21:00   ` [PATCH v3 00/10] reftable: stop using `struct strbuf` Taylor Blau
2024-10-18  7:46     ` karthik nayak
2024-10-18 21:41       ` Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1729140565.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=ethomson@edwardthomson.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=me@ttaylorr.com \
    --cc=shejialuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.