MCPcopy Index your code
hub / github.com/git/git / prep_temp_blob

Function prep_temp_blob

diff.c:4666–4696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4664}
4665
4666static 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
4698static struct diff_tempfile *prepare_temp_file(struct repository *r,
4699 struct diff_filespec *one)

Callers 1

prepare_temp_fileFunction · 0.85

Calls 11

xstrdupFunction · 0.85
init_checkout_metadataFunction · 0.85
mks_tempfile_dtFunction · 0.85
die_errnoFunction · 0.85
convert_to_working_treeFunction · 0.85
write_in_fullFunction · 0.85
close_tempfile_gentlyFunction · 0.85
get_tempfile_pathFunction · 0.85
oid_to_hex_rFunction · 0.85
xsnprintfFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected