git/builtin
Taylor Blau 07647c92ff pack-bitmap: avoid use of static bitmap_writer
The pack-bitmap machinery uses a structure called 'bitmap_writer' to
collect the data necessary to write out .bitmap files. Since its
introduction in 7cc8f971085 (pack-objects: implement bitmap writing,
2013-12-21), there has been a single static bitmap_writer structure,
which is responsible for all bitmap writing-related operations.

In practice, this is OK, since we are only ever writing a single .bitmap
file in a single process (e.g., `git multi-pack-index write --bitmap`,
`git pack-objects --write-bitmap-index`, `git repack -b`, etc.).

However, having a single static variable makes issues like data
ownership unclear, when to free variables, what has/hasn't been
initialized unclear.

Refactor this code to be written in terms of a given bitmap_writer
structure instead of relying on a static global.

Note that this exposes the structure definition of the bitmap_writer at
the pack-bitmap.h level. We could work around this by, e.g., forcing
callers to declare their writers as:

    struct bitmap_writer *writer;
    bitmap_writer_init(&bitmap_writer);

and then declaring `bitmap_writer_init()` as taking in a double-pointer
like so:

    void bitmap_writer_init(struct bitmap_writer **writer);

which would avoid us having to expose the definition of the structure
itself. This patch takes a different approach, since future patches
(like for the ongoing pseudo-merge bitmaps work) will want to modify the
innards of this structure (in the previous example, via pseudo-merge.c).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-05-15 06:52:32 -07:00
..
2024-04-22 16:27:43 -07:00
2024-04-05 10:49:49 -07:00
2020-07-30 19:18:06 -07:00
2024-04-05 15:21:14 -07:00
2024-04-05 10:49:49 -07:00
2024-03-28 14:13:50 -07:00
2024-02-13 10:18:50 -08:00
2024-02-12 09:32:41 -08:00
2024-04-09 14:31:45 -07:00
2024-03-28 14:13:50 -07:00
2023-07-06 11:54:48 -07:00
2024-04-01 13:21:34 -07:00
2024-01-08 14:05:15 -08:00
2024-04-05 10:49:49 -07:00
2024-02-26 09:35:40 -08:00
2023-07-06 11:54:48 -07:00
2024-03-28 14:13:50 -07:00
2024-04-05 10:49:49 -07:00
2024-03-07 15:59:41 -08:00
2024-03-28 14:13:50 -07:00
2024-03-28 14:13:50 -07:00
2024-04-05 10:49:49 -07:00
2024-01-18 12:17:41 -08:00