| 3459 | } |
| 3460 | |
| 3461 | void *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 | |
| 3497 | void move_index_extensions(struct index_state *dst, struct index_state *src) |
| 3498 | { |
no test coverage detected