* Load all of the refs from `dir` (recursively) that could possibly * contain references matching `prefix` into our in-memory cache. If * `prefix` is NULL, prime unconditionally. */
| 282 | * `prefix` is NULL, prime unconditionally. |
| 283 | */ |
| 284 | static void prime_ref_dir(struct ref_dir *dir, const char *prefix) |
| 285 | { |
| 286 | /* |
| 287 | * The hard work of loading loose refs is done by get_ref_dir(), so we |
| 288 | * just need to recurse through all of the sub-directories. We do not |
| 289 | * even need to care about sorting, as traversal order does not matter |
| 290 | * to us. |
| 291 | */ |
| 292 | int i; |
| 293 | for (i = 0; i < dir->nr; i++) { |
| 294 | struct ref_entry *entry = dir->entries[i]; |
| 295 | if (!(entry->flag & REF_DIR)) { |
| 296 | /* Not a directory; no need to recurse. */ |
| 297 | } else if (!prefix) { |
| 298 | /* Recurse in any case: */ |
| 299 | prime_ref_dir(get_ref_dir(entry), NULL); |
| 300 | } else { |
| 301 | switch (overlaps_prefix(entry->name, prefix)) { |
| 302 | case PREFIX_CONTAINS_DIR: |
| 303 | /* |
| 304 | * Recurse, and from here down we |
| 305 | * don't have to check the prefix |
| 306 | * anymore: |
| 307 | */ |
| 308 | prime_ref_dir(get_ref_dir(entry), NULL); |
| 309 | break; |
| 310 | case PREFIX_WITHIN_DIR: |
| 311 | prime_ref_dir(get_ref_dir(entry), prefix); |
| 312 | break; |
| 313 | case PREFIX_EXCLUDES_DIR: |
| 314 | /* No need to prime this directory. */ |
| 315 | break; |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * A level in the reference hierarchy that is currently being iterated |
no test coverage detected