]>
git.ipfire.org Git - thirdparty/git.git/blob - builtin/unpack-file.c
4 static char *create_temp_file(unsigned char *sha1
)
12 buf
= read_sha1_file(sha1
, &type
, &size
);
13 if (!buf
|| type
!= OBJ_BLOB
)
14 die("unable to read blob object %s", sha1_to_hex(sha1
));
16 xsnprintf(path
, sizeof(path
), ".merge_file_XXXXXX");
18 if (write_in_full(fd
, buf
, size
) < 0)
19 die_errno("unable to write temp-file");
24 int cmd_unpack_file(int argc
, const char **argv
, const char *prefix
)
26 unsigned char sha1
[20];
28 if (argc
!= 2 || !strcmp(argv
[1], "-h"))
29 usage("git unpack-file <sha1>");
30 if (get_sha1(argv
[1], sha1
))
31 die("Not a valid object name %s", argv
[1]);
33 git_config(git_default_config
, NULL
);
35 puts(create_temp_file(sha1
));