]> Kevux Git Server - rit/commit
odb/source: introduce source type for robustness
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Mar 2026 14:19:45 +0000 (15:19 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2026 19:45:15 +0000 (11:45 -0800)
commit87842f68352040858f581b64509932fb91c64f0f
treec94012f8d76c89ea5750289c504a7d179ac8e75a
parent7e0aa0ab803405076b82ca66d328d314d17870ac
odb/source: introduce source type for robustness

When a caller holds a `struct odb_source`, they have no way of telling
what type the source is. This doesn't really cause any problems in the
current status quo as we only have a single type anyway, "files". But
going forward we expect to add more types, and if so it will become
necessary to tell the sources apart.

Introduce a new enum to cover this use case and assert that the given
source actually matches the target source when performing the downcast.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb/source-files.c
odb/source-files.h
odb/source.c
odb/source.h