3 static char *create_temp_file(unsigned char *sha1)
 
  11         buf = read_sha1_file(sha1, &type, &size);
 
  12         if (!buf || type != OBJ_BLOB)
 
  13                 die("unable to read blob object %s", sha1_to_hex(sha1));
 
  15         strcpy(path, ".merge_file_XXXXXX");
 
  17         if (write_in_full(fd, buf, size) != size)
 
  18                 die_errno("unable to write temp-file");
 
  23 int cmd_unpack_file(int argc, const char **argv, const char *prefix)
 
  25         unsigned char sha1[20];
 
  27         if (argc != 2 || !strcmp(argv[1], "-h"))
 
  28                 usage("git unpack-file <sha1>");
 
  29         if (get_sha1(argv[1], sha1))
 
  30                 die("Not a valid object name %s", argv[1]);
 
  32         git_config(git_default_config, NULL);
 
  34         puts(create_temp_file(sha1));