| 4664 | } |
| 4665 | |
| 4666 | static void prep_temp_blob(struct index_state *istate, |
| 4667 | const char *path, struct diff_tempfile *temp, |
| 4668 | void *blob, |
| 4669 | unsigned long size, |
| 4670 | const struct object_id *oid, |
| 4671 | int mode) |
| 4672 | { |
| 4673 | struct strbuf buf = STRBUF_INIT; |
| 4674 | char *path_dup = xstrdup(path); |
| 4675 | const char *base = basename(path_dup); |
| 4676 | struct checkout_metadata meta; |
| 4677 | |
| 4678 | init_checkout_metadata(&meta, NULL, NULL, oid); |
| 4679 | |
| 4680 | temp->tempfile = mks_tempfile_dt("git-blob-XXXXXX", base); |
| 4681 | if (!temp->tempfile) |
| 4682 | die_errno("unable to create temp-file"); |
| 4683 | if (convert_to_working_tree(istate, path, |
| 4684 | (const char *)blob, (size_t)size, &buf, &meta)) { |
| 4685 | blob = buf.buf; |
| 4686 | size = buf.len; |
| 4687 | } |
| 4688 | if (write_in_full(temp->tempfile->fd, blob, size) < 0 || |
| 4689 | close_tempfile_gently(temp->tempfile)) |
| 4690 | die_errno("unable to write temp-file"); |
| 4691 | temp->name = get_tempfile_path(temp->tempfile); |
| 4692 | oid_to_hex_r(temp->hex, oid); |
| 4693 | xsnprintf(temp->mode, sizeof(temp->mode), "%06o", mode); |
| 4694 | strbuf_release(&buf); |
| 4695 | free(path_dup); |
| 4696 | } |
| 4697 | |
| 4698 | static struct diff_tempfile *prepare_temp_file(struct repository *r, |
| 4699 | struct diff_filespec *one) |
no test coverage detected