v1: https://lore.kernel.org/git/20221206103736.53909-1-karthik.188@xxxxxxxxx/ v2: https://lore.kernel.org/git/CAOLa=ZSsFGBw3ta1jWN8cmUch2ca=zTEjp1xMA6Linafx9W53g@xxxxxxxxxxxxxx/T/#t v3: https://lore.kernel.org/git/20221216093552.3171319-1-karthik.188@xxxxxxxxx/ v4: https://lore.kernel.org/git/cover.1671630304.git.karthik.188@xxxxxxxxx v5: https://lore.kernel.org/git/cover.1671793109.git.karthik.188@xxxxxxxxx/ v6: https://lore.kernel.org/git/cover.1673521102.git.karthik.188@xxxxxxxxx/ Given a pathname, git-check-attr(1) will list the attributes which apply to that pathname by reading all relevant gitattributes files. Currently there is no way to specify a tree-ish to read the gitattributes from. This is specifically useful in bare repositories wherein the gitattributes are only present in the git working tree but not available directly on the filesystem. This series aims to add a new flag `--source` to git-check-attr(1) which allows us to read gitattributes from the specified tree-ish. Changes since v6: - s/read_object_file/repo_read_object_file to make it more consistent - In attr.h define 'struct object_id' instead of including 'hash.h' Range-diff against v5: 1: 6224754179 = 1: 6224754179 t0003: move setup for `--all` into new block 2: 57f5957127 ! 2: 0ca8b24589 attr: add flag `--source` to work with tree-ish @@ attr.c: static struct attr_stack *read_attr_from_file(const char *path, unsigned + if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode)) + return NULL; + -+ buf = read_object_file(&oid, &type, &sz); ++ buf = repo_read_object_file(istate->repo, &oid, &type, &sz); + if (!buf || type != OBJ_BLOB) { + free(buf); + return NULL; @@ attr.c: void git_check_attr(struct index_state *istate, ## attr.h ## @@ - #ifndef ATTR_H - #define ATTR_H + */ + + struct index_state; ++struct object_id; -+#include "hash.h" -+ /** - * gitattributes mechanism gives a uniform way to associate various attributes - * to set of paths. + * An attribute is an opaque object that is identified by its name. Pass the @@ attr.h: void attr_check_free(struct attr_check *check); const char *git_attr_name(const struct git_attr *); Karthik Nayak (2): t0003: move setup for `--all` into new block attr: add flag `--source` to work with tree-ish Documentation/git-check-attr.txt | 9 ++- archive.c | 2 +- attr.c | 97 +++++++++++++++++++++++--------- attr.h | 6 +- builtin/check-attr.c | 35 +++++++----- builtin/pack-objects.c | 2 +- convert.c | 2 +- ll-merge.c | 4 +- pathspec.c | 2 +- t/t0003-attributes.sh | 48 +++++++++++++++- userdiff.c | 2 +- ws.c | 2 +- 12 files changed, 156 insertions(+), 55 deletions(-) -- 2.39.0