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

Function index_fd

object-file.c:1358–1402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1356}
1357
1358int index_fd(struct index_state *istate, struct object_id *oid,
1359 int fd, struct stat *st,
1360 enum object_type type, const char *path, unsigned flags)
1361{
1362 int ret;
1363
1364 /*
1365 * Call xsize_t() only when needed to avoid potentially unnecessary
1366 * die() for large files.
1367 */
1368 if (type == OBJ_BLOB && path && would_convert_to_git_filter_fd(istate, path)) {
1369 ret = index_stream_convert_blob(istate, oid, fd, path, flags);
1370 } else if (!S_ISREG(st->st_mode)) {
1371 ret = index_pipe(istate, oid, fd, type, path, flags);
1372 } else if ((st->st_size >= 0 &&
1373 (size_t)st->st_size <= repo_settings_get_big_file_threshold(istate->repo)) ||
1374 type != OBJ_BLOB ||
1375 (path && would_convert_to_git(istate, path))) {
1376 ret = index_core(istate, oid, fd, xsize_t(st->st_size),
1377 type, path, flags);
1378 } else {
1379 struct odb_write_stream stream;
1380 odb_write_stream_from_fd(&stream, fd, xsize_t(st->st_size));
1381
1382 if (flags & INDEX_WRITE_OBJECT) {
1383 struct object_database *odb = the_repository->objects;
1384 struct odb_transaction *transaction = odb_transaction_begin(odb);
1385
1386 ret = odb_transaction_write_object_stream(odb->transaction,
1387 &stream,
1388 xsize_t(st->st_size),
1389 oid);
1390 odb_transaction_commit(transaction);
1391 } else {
1392 ret = hash_blob_stream(&stream,
1393 the_repository->hash_algo, oid,
1394 xsize_t(st->st_size));
1395 }
1396
1397 odb_write_stream_release(&stream);
1398 }
1399
1400 close(fd);
1401 return ret;
1402}
1403
1404int index_path(struct index_state *istate, struct object_id *oid,
1405 const char *path, struct stat *st, unsigned flags)

Callers 6

index_pathFunction · 0.85
ce_compare_dataFunction · 0.85
import_objectFunction · 0.85
hash_fdFunction · 0.85
use_wt_fileFunction · 0.85

Calls 13

index_pipeFunction · 0.85
would_convert_to_gitFunction · 0.85
index_coreFunction · 0.85
xsize_tFunction · 0.85
odb_write_stream_from_fdFunction · 0.85
odb_transaction_beginFunction · 0.85
odb_transaction_commitFunction · 0.85
hash_blob_streamFunction · 0.85

Tested by

no test coverage detected