Commit e6877b3
committed
odb: add odb_source_files_try() for heterogeneous source iteration
The odb_source vtable introduced in this release allows multiple
backend implementations via the odb_source_type enum. However,
source-chain iteration sites that need files-specific internals
(pack store, loose cache, MIDX) currently use
odb_source_files_downcast(), which calls BUG() for non-files
source types. This makes it impossible to add a non-files source
to the chain without crashing.
Add odb_source_files_try() as a companion to the existing
downcast function. It returns NULL for non-files sources instead
of aborting. This follows the pattern used elsewhere in git where
a "try" or "maybe" variant provides a fallback path while the
strict version retains its safety guarantee.
The existing odb_source_files_downcast() is unchanged and
continues to BUG() on type mismatch, protecting call sites that
should only ever receive a files source.
A subsequent commit will convert the source-chain iteration sites
to use this new helper.
Signed-off-by: Aaron Paterson <apaterson@pm.me>1 parent dc6ecd5 commit e6877b3
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
35 | 49 | | |
0 commit comments