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

Function index_path

object-file.c:1404–1440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1402}
1403
1404int index_path(struct index_state *istate, struct object_id *oid,
1405 const char *path, struct stat *st, unsigned flags)
1406{
1407 int fd;
1408 struct strbuf sb = STRBUF_INIT;
1409 int rc = 0;
1410
1411 switch (st->st_mode & S_IFMT) {
1412 case S_IFREG:
1413 fd = open(path, O_RDONLY);
1414 if (fd < 0)
1415 return error_errno("open(\"%s\")", path);
1416 if (index_fd(istate, oid, fd, st, OBJ_BLOB, path, flags) < 0)
1417 return error(_("%s: failed to insert into database"),
1418 path);
1419 break;
1420 case S_IFLNK:
1421 if (strbuf_readlink(&sb, path, st->st_size))
1422 return error_errno("readlink(\"%s\")", path);
1423 if (!(flags & INDEX_WRITE_OBJECT))
1424 hash_object_file(istate->repo->hash_algo, sb.buf, sb.len,
1425 OBJ_BLOB, oid);
1426 else if (odb_write_object(istate->repo->objects, sb.buf, sb.len, OBJ_BLOB, oid))
1427 rc = error(_("%s: failed to insert into database"), path);
1428 strbuf_release(&sb);
1429 break;
1430 case S_IFDIR:
1431 if (repo_resolve_gitlink_ref(istate->repo, path, "HEAD", oid))
1432 return error(_("'%s' does not have a commit checked out"), path);
1433 if (&hash_algos[oid->algo] != istate->repo->hash_algo)
1434 return error(_("cannot add a submodule of a different hash algorithm"));
1435 break;
1436 default:
1437 return error(_("%s: unsupported file type"), path);
1438 }
1439 return rc;
1440}
1441
1442int read_pack_header(int fd, struct pack_header *header)
1443{

Callers 4

notes_merge_commitFunction · 0.85
diff_fill_oid_infoFunction · 0.85
add_to_indexFunction · 0.85
add_one_pathFunction · 0.85

Calls 8

error_errnoFunction · 0.85
index_fdFunction · 0.85
errorFunction · 0.85
strbuf_readlinkFunction · 0.85
hash_object_fileFunction · 0.85
odb_write_objectFunction · 0.85
strbuf_releaseFunction · 0.85
repo_resolve_gitlink_refFunction · 0.85

Tested by

no test coverage detected