From 9f9c40cf34c29d4ad700d9869435d159056fa6fb Mon Sep 17 00:00:00 2001 From: John Cai Date: Fri, 13 Oct 2023 17:39:30 +0000 Subject: attr: add attr.tree for setting the treeish to read attributes from 44451a2 (attr: teach "--attr-source=" global option to "git", 2023-05-06) provided the ability to pass in a treeish as the attr source. In the context of serving Git repositories as bare repos like we do at GitLab however, it would be easier to point --attr-source to HEAD for all commands by setting it once. Add a new config attr.tree that allows this. Signed-off-by: John Cai Signed-off-by: Junio C Hamano --- attr.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'attr.c') diff --git a/attr.c b/attr.c index efc061527f..a4b818ca5a 100644 --- a/attr.c +++ b/attr.c @@ -24,6 +24,8 @@ #include "tree-walk.h" #include "object-name.h" +const char *git_attr_tree; + const char git_attr__true[] = "(builtin)true"; const char git_attr__false[] = "\0(builtin)false"; static const char git_attr__unknown[] = "(builtin)unknown"; @@ -1185,6 +1187,11 @@ static void compute_default_attr_source(struct object_id *attr_source) if (!default_attr_source_tree_object_name) default_attr_source_tree_object_name = getenv(GIT_ATTR_SOURCE_ENVIRONMENT); + if (!default_attr_source_tree_object_name && git_attr_tree) { + default_attr_source_tree_object_name = git_attr_tree; + ignore_bad_attr_tree = 1; + } + if (!default_attr_source_tree_object_name && startup_info->have_repository && is_bare_repository()) { -- cgit 1.2.3-korg