| 8 | #include "odb.h" |
| 9 | |
| 10 | static char *create_temp_file(struct object_id *oid) |
| 11 | { |
| 12 | static char path[50]; |
| 13 | void *buf; |
| 14 | enum object_type type; |
| 15 | size_t size; |
| 16 | int fd; |
| 17 | |
| 18 | buf = odb_read_object(the_repository->objects, oid, &type, &size); |
| 19 | if (!buf || type != OBJ_BLOB) |
| 20 | die("unable to read blob object %s", oid_to_hex(oid)); |
| 21 | |
| 22 | xsnprintf(path, sizeof(path), ".merge_file_XXXXXX"); |
| 23 | fd = xmkstemp(path); |
| 24 | if (write_in_full(fd, buf, size) < 0) |
| 25 | die_errno("unable to write temp-file"); |
| 26 | close(fd); |
| 27 | free(buf); |
| 28 | return path; |
| 29 | } |
| 30 | |
| 31 | static const char usage_msg[] = |
| 32 | "git unpack-file <blob>"; |
no test coverage detected