]> git.99rst.org Git - git.git/commit
odb/source: generalize `reprepare()` callback
authorPatrick Steinhardt <redacted>
Mon, 22 Jun 2026 08:47:54 +0000 (10:47 +0200)
committerJunio C Hamano <redacted>
Mon, 22 Jun 2026 17:41:03 +0000 (10:41 -0700)
commit27bba4258b9e4bd7a0313e3bb4cce8aeba268712
treedeefeca1f3ac69c721df415a3a9f5572b2e75874
parent1bba44eee3f25b9ce68687d0c85ff55a1840ea71
odb/source: generalize `reprepare()` callback

The `reprepare()` callback function can be used to flush caches of a
given object source and then prepare it anew. This is for example used
when a concurrent process may have written new objects. Ultimately, this
can be seen as doing two separate steps:

  1. We drop any caches.

  2. We prepare the source.

We have one callsite in git-grep(1) though that really only want to do
(2). This is done by reaching into the "files" backend directly and then
calling `odb_source_packed_prepare()`, which of course may not work with
alternate backends.

We could in theory just call `reprepare()` here, and that would likely
not have any significant downside. But this would certainly feel like a
code smell.

Instead, generalize the `reprepare()` callback to `prepare()` with a
flag that optionally instructs the backend to also flush the caches,
which allows us to drop the external `odb_source_packed_prepare()`
declaration.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/grep.c
midx.c
odb.c
odb.h
odb/source-files.c
odb/source-inmemory.c
odb/source-loose.c
odb/source-packed.c
odb/source-packed.h
odb/source.h
packfile.c
git clone https://git.99rst.org/PROJECT