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

Function create_temp_file

builtin/unpack-file.c:10–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "odb.h"
9
10static 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
31static const char usage_msg[] =
32"git unpack-file <blob>";

Callers 1

cmd_unpack_fileFunction · 0.85

Calls 7

odb_read_objectFunction · 0.85
oid_to_hexFunction · 0.85
xsnprintfFunction · 0.85
xmkstempFunction · 0.85
write_in_fullFunction · 0.85
die_errnoFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected