MCPcopy Index your code
hub / github.com/git/git / update_one

Function update_one

cache-tree.c:257–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257static 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;

Callers 1

cache_tree_updateFunction · 0.70

Calls 15

oidcpyFunction · 0.85
odb_has_objectFunction · 0.85
find_subtreeFunction · 0.85
discard_unused_subtreesFunction · 0.85
strbuf_initFunction · 0.85
must_check_existenceFunction · 0.85
is_null_oidFunction · 0.85
strbuf_releaseFunction · 0.85
errorFunction · 0.85
oid_to_hexFunction · 0.85
is_empty_tree_oidFunction · 0.85
strbuf_growFunction · 0.85

Tested by

no test coverage detected