From 44451a2e5eec5360378be23e2cdbd9ecee49e14e Mon Sep 17 00:00:00 2001 From: John Cai Date: Sat, 6 May 2023 04:15:29 +0000 Subject: attr: teach "--attr-source=" global option to "git" Earlier, 47cfc9bd (attr: add flag `--source` to work with tree-ish, 2023-01-14) taught "git check-attr" the "--source=" option to allow it to read attribute files from a tree-ish, but did so only for the command. Just like "check-attr" users wanted a way to use attributes from a tree-ish and not from the working tree files, users of other commands (like "git diff") would benefit from the same. Undo most of the UI change the commit made, while keeping the internal logic to read attributes from a given tree-ish. Expose the internal logic via a new "--attr-source=" command line option given to "git", so that it can be used with any git command that runs as part of the main git process. Additionally, add an environment variable GIT_ATTR_SOURCE that is set when --attr-source is passed in, so that subprocesses use the same value for the attributes source tree. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- userdiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'userdiff.c') diff --git a/userdiff.c b/userdiff.c index eaec6ebb5e..664c7c1402 100644 --- a/userdiff.c +++ b/userdiff.c @@ -444,7 +444,7 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate, check = attr_check_initl("diff", NULL); if (!path) return NULL; - git_check_attr(istate, NULL, path, check); + git_check_attr(istate, path, check); if (ATTR_TRUE(check->items[0].value)) return &driver_true; -- cgit v1.2.3