| 255 | } |
| 256 | |
| 257 | static int update_one(struct cache_tree *it, |
| 258 | struct cache_entry **cache, |
| 259 | int entries, |
| 260 | const char *base, |
| 261 | int baselen, |
| 262 | int *skip_count, |
| 263 | int flags) |
| 264 | { |
| 265 | struct strbuf buffer; |
| 266 | int missing_ok = flags & WRITE_TREE_MISSING_OK; |
| 267 | int dryrun = flags & WRITE_TREE_DRY_RUN; |
| 268 | int repair = flags & WRITE_TREE_REPAIR; |
| 269 | int to_invalidate = 0; |
| 270 | int i; |
| 271 | |
| 272 | assert(!(dryrun && repair)); |
| 273 | |
| 274 | *skip_count = 0; |
| 275 | |
| 276 | /* |
| 277 | * If the first entry of this region is a sparse directory |
| 278 | * entry corresponding exactly to 'base', then this cache_tree |
| 279 | * struct is a "leaf" in the data structure, pointing to the |
| 280 | * tree OID specified in the entry. |
| 281 | */ |
| 282 | if (entries > 0) { |
| 283 | const struct cache_entry *ce = cache[0]; |
| 284 | |
| 285 | if (S_ISSPARSEDIR(ce->ce_mode) && |
| 286 | ce->ce_namelen == baselen && |
| 287 | !strncmp(ce->name, base, baselen)) { |
| 288 | it->entry_count = 1; |
| 289 | oidcpy(&it->oid, &ce->oid); |
| 290 | return 1; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | if (0 <= it->entry_count && |
| 295 | odb_has_object(the_repository->objects, &it->oid, |
| 296 | ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) |
| 297 | return it->entry_count; |
| 298 | |
| 299 | /* |
| 300 | * We first scan for subtrees and update them; we start by |
| 301 | * marking existing subtrees -- the ones that are unmarked |
| 302 | * should not be in the result. |
| 303 | */ |
| 304 | for (i = 0; i < it->subtree_nr; i++) |
| 305 | it->down[i]->used = 0; |
| 306 | |
| 307 | /* |
| 308 | * Find the subtrees and update them. |
| 309 | */ |
| 310 | i = 0; |
| 311 | while (i < entries) { |
| 312 | const struct cache_entry *ce = cache[i]; |
| 313 | struct cache_tree_sub *sub; |
| 314 | const char *path, *slash; |
no test coverage detected