4 #include "object-name.h"
5 #include "object-store.h"
8 static char *create_temp_file(struct object_id
*oid
)
12 enum object_type type
;
16 buf
= repo_read_object_file(the_repository
, oid
, &type
, &size
);
17 if (!buf
|| type
!= OBJ_BLOB
)
18 die("unable to read blob object %s", oid_to_hex(oid
));
20 xsnprintf(path
, sizeof(path
), ".merge_file_XXXXXX");
22 if (write_in_full(fd
, buf
, size
) < 0)
23 die_errno("unable to write temp-file");
29 int cmd_unpack_file(int argc
, const char **argv
, const char *prefix UNUSED
)
33 if (argc
!= 2 || !strcmp(argv
[1], "-h"))
34 usage("git unpack-file <blob>");
35 if (repo_get_oid(the_repository
, argv
[1], &oid
))
36 die("Not a valid object name %s", argv
[1]);
38 git_config(git_default_config
, NULL
);
40 puts(create_temp_file(&oid
));