Commit a8303b1
committed
odb: use odb_source_files_try() in source-chain iterations
Convert all source-chain iteration sites that access
files-specific internals (pack store, loose cache, MIDX) to use
odb_source_files_try() instead of odb_source_files_downcast().
These loops iterate the full source chain, which may include
alternates. When a non-files backend is added to the chain (as an
alternate or additional source), these sites must skip it rather
than abort. The _try() helper returns NULL for non-files sources,
and each site checks for NULL before accessing files-specific
members.
Call sites that access odb->sources directly (the primary source,
which is always a files backend) or that are inside files-backend
vtable callbacks continue to use odb_source_files_downcast() with
its BUG() safety guarantee.
Sites converted (22 across 11 files):
- loose.c: loose object map loading and oid lookup
- midx.c: multi-pack-index access and cleanup
- object-file.c: loose cache and reprepare
- object-name.c: short object filename search
- packfile.c: window/fd management, pack entry lookup
- packfile.h: repo_for_each_pack iterator macros
- commit-graph.c: packed object enumeration
- builtin/cat-file.c: batch object iteration
- builtin/fast-import.c: pack lookup in store/stream
- builtin/grep.c: pack preparation
- builtin/pack-objects.c: cruft/kept pack enumeration
Add a unit test verifying odb_source_files_try() returns the
correct backend for ODB_SOURCE_FILES and NULL for other types.
Note: repo_approximate_object_count() and has_object_pack() will
not account for objects in non-files sources. These are
display and optimization functions respectively, and a follow-up
series can add vtable callbacks to address this.
Signed-off-by: Aaron Paterson <apaterson@pm.me>1 parent e6877b3 commit a8303b1
14 files changed
Lines changed: 117 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1544 | 1544 | | |
1545 | 1545 | | |
1546 | 1546 | | |
| 1547 | + | |
1547 | 1548 | | |
1548 | 1549 | | |
1549 | 1550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
882 | 882 | | |
883 | 883 | | |
884 | 884 | | |
885 | | - | |
886 | | - | |
887 | | - | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
888 | 891 | | |
889 | 892 | | |
890 | 893 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
982 | 982 | | |
983 | 983 | | |
984 | 984 | | |
985 | | - | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
986 | 988 | | |
987 | 989 | | |
988 | 990 | | |
| |||
1189 | 1191 | | |
1190 | 1192 | | |
1191 | 1193 | | |
1192 | | - | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
1193 | 1197 | | |
1194 | 1198 | | |
1195 | 1199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1219 | 1219 | | |
1220 | 1220 | | |
1221 | 1221 | | |
1222 | | - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
1223 | 1225 | | |
1224 | 1226 | | |
1225 | 1227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1531 | 1531 | | |
1532 | 1532 | | |
1533 | 1533 | | |
1534 | | - | |
1535 | | - | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
1536 | 1539 | | |
1537 | 1540 | | |
1538 | 1541 | | |
| |||
1754 | 1757 | | |
1755 | 1758 | | |
1756 | 1759 | | |
1757 | | - | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
1758 | 1763 | | |
1759 | 1764 | | |
1760 | 1765 | | |
| |||
4350 | 4355 | | |
4351 | 4356 | | |
4352 | 4357 | | |
4353 | | - | |
| 4358 | + | |
| 4359 | + | |
| 4360 | + | |
4354 | 4361 | | |
4355 | 4362 | | |
4356 | 4363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1981 | 1981 | | |
1982 | 1982 | | |
1983 | 1983 | | |
1984 | | - | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
1985 | 1987 | | |
1986 | 1988 | | |
1987 | 1989 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
235 | 238 | | |
236 | 239 | | |
237 | 240 | | |
238 | | - | |
239 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
240 | 246 | | |
241 | 247 | | |
242 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
806 | 808 | | |
807 | 809 | | |
808 | 810 | | |
809 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
810 | 814 | | |
811 | 815 | | |
812 | 816 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1879 | 1879 | | |
1880 | 1880 | | |
1881 | 1881 | | |
1882 | | - | |
1883 | | - | |
| 1882 | + | |
| 1883 | + | |
1884 | 1884 | | |
1885 | | - | |
1886 | | - | |
1887 | | - | |
| 1885 | + | |
1888 | 1886 | | |
1889 | 1887 | | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
1890 | 1896 | | |
1891 | 1897 | | |
1892 | 1898 | | |
| |||
1919 | 1925 | | |
1920 | 1926 | | |
1921 | 1927 | | |
1922 | | - | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
1923 | 1931 | | |
1924 | 1932 | | |
1925 | 1933 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
0 commit comments