MCPcopy Create free account
hub / github.com/git/git / index_mem

Function index_mem

object-file.c:984–1025  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

982}
983
984static int index_mem(struct index_state *istate,
985 struct object_id *oid,
986 const void *buf, size_t size,
987 enum object_type type,
988 const char *path, unsigned flags)
989{
990 struct strbuf nbuf = STRBUF_INIT;
991 int ret = 0;
992 int write_object = flags & INDEX_WRITE_OBJECT;
993
994 if (!type)
995 type = OBJ_BLOB;
996
997 /*
998 * Convert blobs to git internal format
999 */
1000 if ((type == OBJ_BLOB) && path) {
1001 if (convert_to_git(istate, path, buf, size, &nbuf,
1002 get_conv_flags(flags))) {
1003 buf = nbuf.buf;
1004 size = nbuf.len;
1005 }
1006 }
1007 if (flags & INDEX_FORMAT_CHECK) {
1008 struct fsck_options opts;
1009
1010 fsck_options_init(&opts, the_repository, FSCK_OPTIONS_DEFAULT);
1011 opts.strict = 1;
1012 opts.error_func = hash_format_check_report;
1013 if (fsck_buffer(null_oid(istate->repo->hash_algo), type, buf, size, &opts))
1014 die(_("refusing to create malformed object"));
1015 fsck_finish(&opts);
1016 }
1017
1018 if (write_object)
1019 ret = odb_write_object(istate->repo->objects, buf, size, type, oid);
1020 else
1021 hash_object_file(istate->repo->hash_algo, buf, size, type, oid);
1022
1023 strbuf_release(&nbuf);
1024 return ret;
1025}
1026
1027static int index_stream_convert_blob(struct index_state *istate,
1028 struct object_id *oid,

Callers 2

index_pipeFunction · 0.85
index_coreFunction · 0.85

Calls 10

convert_to_gitFunction · 0.85
get_conv_flagsFunction · 0.85
fsck_options_initFunction · 0.85
fsck_bufferFunction · 0.85
null_oidFunction · 0.85
fsck_finishFunction · 0.85
odb_write_objectFunction · 0.85
hash_object_fileFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected