MCPcopy Create free account
hub / github.com/git/git / read_blob_data_from_index

Function read_blob_data_from_index

read-cache.c:3461–3495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3459}
3460
3461void *read_blob_data_from_index(struct index_state *istate,
3462 const char *path, unsigned long *size)
3463{
3464 int pos, len;
3465 size_t sz;
3466 enum object_type type;
3467 void *data;
3468
3469 len = strlen(path);
3470 pos = index_name_pos(istate, path, len);
3471 if (pos < 0) {
3472 /*
3473 * We might be in the middle of a merge, in which
3474 * case we would read stage #2 (ours).
3475 */
3476 int i;
3477 for (i = -pos - 1;
3478 (pos < 0 && i < istate->cache_nr &&
3479 !strcmp(istate->cache[i]->name, path));
3480 i++)
3481 if (ce_stage(istate->cache[i]) == 2)
3482 pos = i;
3483 }
3484 if (pos < 0)
3485 return NULL;
3486 data = odb_read_object(the_repository->objects, &istate->cache[pos]->oid,
3487 &type, &sz);
3488 if (!data || type != OBJ_BLOB) {
3489 free(data);
3490 return NULL;
3491 }
3492 if (size)
3493 *size = cast_size_t_to_ulong(sz);
3494 return data;
3495}
3496
3497void move_index_extensions(struct index_state *dst, struct index_state *src)
3498{

Callers 3

read_attr_from_indexFunction · 0.85
has_crlf_in_indexFunction · 0.85

Calls 3

index_name_posFunction · 0.85
odb_read_objectFunction · 0.85
cast_size_t_to_ulongFunction · 0.85

Tested by

no test coverage detected