]> git.99rst.org Git - git.git/commit
builtin/gc: avoid global state in `gc_before_repack()`
authorPatrick Steinhardt <redacted>
Tue, 3 Jun 2025 14:01:19 +0000 (16:01 +0200)
committerJunio C Hamano <redacted>
Tue, 3 Jun 2025 15:30:52 +0000 (08:30 -0700)
commitd2b084c66037f1a77b3e061ae7e4d96cbdbf6c05
tree544cea981974816be57ec0fbbcaf5e6d278439c1
parent697202b0b1c7c02208c620f96c608e0817d079dd
builtin/gc: avoid global state in `gc_before_repack()`

The `gc_before_repack()` should only ever run once in git-gc(1), but we
may end up calling it twice when the "--detach" flag is passed. The
duplicated call is avoided though via a static flag in this function.

This pattern is somewhat unintuitive though. Refactor it to drop the
static flag and instead guard the second call of `gc_before_repack()`
via `opts.detach`.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/gc.c
git clone https://git.99rst.org/PROJECT