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

Function read_attr

attr.c:841–872  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841static struct attr_stack *read_attr(struct index_state *istate,
842 const struct object_id *tree_oid,
843 const char *path, unsigned flags)
844{
845 struct attr_stack *res = NULL;
846
847 if (direction == GIT_ATTR_INDEX) {
848 res = read_attr_from_index(istate, path, flags);
849 } else if (tree_oid) {
850 res = read_attr_from_blob(istate, tree_oid, path, flags);
851 } else if (!is_bare_repository()) {
852 if (direction == GIT_ATTR_CHECKOUT) {
853 res = read_attr_from_index(istate, path, flags);
854 if (!res)
855 res = read_attr_from_file(path, flags);
856 } else if (direction == GIT_ATTR_CHECKIN) {
857 res = read_attr_from_file(path, flags);
858 if (!res)
859 /*
860 * There is no checked out .gitattributes file
861 * there, but we might have it in the index.
862 * We allow operation in a sparsely checked out
863 * work tree, so read from it.
864 */
865 res = read_attr_from_index(istate, path, flags);
866 }
867 }
868
869 if (!res)
870 CALLOC_ARRAY(res, 1);
871 return res;
872}
873
874const char *git_attr_system_file(void)
875{

Callers 2

bootstrap_attr_stackFunction · 0.85
prepare_attr_stackFunction · 0.85

Calls 4

read_attr_from_indexFunction · 0.85
read_attr_from_blobFunction · 0.85
is_bare_repositoryFunction · 0.85
read_attr_from_fileFunction · 0.85

Tested by

no test coverage detected