Merge branch 'jc/no-default-attr-tree-in-bare'

Git 2.43 started using the tree of HEAD as the source of attributes
in a bare repository, which has severe performance implications.
For now, revert the change, without ripping out a more explicit
support for the attr.tree configuration variable.

* jc/no-default-attr-tree-in-bare:
  stop using HEAD for attributes in bare repository by default
This commit is contained in:
Junio C Hamano
2024-05-13 10:19:46 -07:00
3 changed files with 10 additions and 10 deletions

7
attr.c
View File

@ -1222,13 +1222,6 @@ static void compute_default_attr_source(struct object_id *attr_source)
ignore_bad_attr_tree = 1; ignore_bad_attr_tree = 1;
} }
if (!default_attr_source_tree_object_name &&
startup_info->have_repository &&
is_bare_repository()) {
default_attr_source_tree_object_name = "HEAD";
ignore_bad_attr_tree = 1;
}
if (!default_attr_source_tree_object_name || !is_null_oid(attr_source)) if (!default_attr_source_tree_object_name || !is_null_oid(attr_source))
return; return;

View File

@ -398,13 +398,19 @@ test_expect_success 'bad attr source defaults to reading .gitattributes file' '
) )
' '
test_expect_success 'bare repo defaults to reading .gitattributes from HEAD' ' test_expect_success 'bare repo no longer defaults to reading .gitattributes from HEAD' '
test_when_finished rm -rf test bare_with_gitattribute && test_when_finished rm -rf test bare_with_gitattribute &&
git init test && git init test &&
test_commit -C test gitattributes .gitattributes "f/path test=val" && test_commit -C test gitattributes .gitattributes "f/path test=val" &&
git clone --bare test bare_with_gitattribute && git clone --bare test bare_with_gitattribute &&
echo "f/path: test: val" >expect &&
echo "f/path: test: unspecified" >expect &&
git -C bare_with_gitattribute check-attr test -- f/path >actual && git -C bare_with_gitattribute check-attr test -- f/path >actual &&
test_cmp expect actual &&
echo "f/path: test: val" >expect &&
git -C bare_with_gitattribute -c attr.tree=HEAD \
check-attr test -- f/path >actual &&
test_cmp expect actual test_cmp expect actual
' '

View File

@ -133,7 +133,8 @@ test_expect_success 'git archive vs. bare' '
' '
test_expect_success 'git archive with worktree attributes, bare' ' test_expect_success 'git archive with worktree attributes, bare' '
(cd bare && git archive --worktree-attributes HEAD) >bare-worktree.tar && (cd bare &&
git -c attr.tree=HEAD archive --worktree-attributes HEAD) >bare-worktree.tar &&
(mkdir bare-worktree && cd bare-worktree && "$TAR" xf -) <bare-worktree.tar (mkdir bare-worktree && cd bare-worktree && "$TAR" xf -) <bare-worktree.tar
' '