reftable/stack: add mechanism to notify callers on reload

Reftable stacks are reloaded in two cases:

  - When calling `reftable_stack_reload()`, if the stat-cache tells us
    that the stack has been modified.

  - When committing a reftable addition.

While callers can figure out the second case, they do not have a
mechanism to figure out whether `reftable_stack_reload()` led to an
actual reload of the on-disk data. All they can do is thus to assume
that data is always being reloaded in that case.

Improve the situation by introducing a new `on_reload()` callback to the
reftable options. If provided, the function will be invoked every time
the stack has indeed been reloaded. This allows callers to invalidate
data that depends on the current stack data.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-11-26 07:42:59 +01:00
committed by Junio C Hamano
parent 96e7cb83b6
commit eb22c1b46b
2 changed files with 13 additions and 0 deletions

View File

@@ -548,6 +548,10 @@ out:
close(fd);
free_names(names);
free_names(names_after);
if (st->opts.on_reload)
st->opts.on_reload(st->opts.on_reload_payload);
return err;
}