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

Function index_core

object-file.c:1070–1097  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1068#define SMALL_FILE_SIZE (32*1024)
1069
1070static int index_core(struct index_state *istate,
1071 struct object_id *oid, int fd, size_t size,
1072 enum object_type type, const char *path,
1073 unsigned flags)
1074{
1075 int ret;
1076
1077 if (!size) {
1078 ret = index_mem(istate, oid, "", size, type, path, flags);
1079 } else if (size <= SMALL_FILE_SIZE) {
1080 char *buf = xmalloc(size);
1081 ssize_t read_result = read_in_full(fd, buf, size);
1082 if (read_result < 0)
1083 ret = error_errno(_("read error while indexing %s"),
1084 path ? path : "<unknown>");
1085 else if ((size_t) read_result != size)
1086 ret = error(_("short read while indexing %s"),
1087 path ? path : "<unknown>");
1088 else
1089 ret = index_mem(istate, oid, buf, size, type, path, flags);
1090 free(buf);
1091 } else {
1092 void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
1093 ret = index_mem(istate, oid, buf, size, type, path, flags);
1094 munmap(buf, size);
1095 }
1096 return ret;
1097}
1098
1099static int already_written(struct odb_transaction_files *transaction,
1100 struct object_id *oid)

Callers 1

index_fdFunction · 0.85

Calls 6

index_memFunction · 0.85
read_in_fullFunction · 0.85
error_errnoFunction · 0.85
errorFunction · 0.85
xmmapFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected