| 839 | } |
| 840 | |
| 841 | static 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 | |
| 874 | const char *git_attr_system_file(void) |
| 875 | { |
no test coverage detected