aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-05-06 22:50:24 -0700
committerJunio C Hamano <gitster@pobox.com>2024-05-06 22:50:24 -0700
commite9e8dd8801360e503db89be9372dc7ab719c4218 (patch)
tree67c2b98e7aa235d163954de7d04defd33777a9f1
parentd4cc1ec35f3bcce816b69986ca41943f6ce21377 (diff)
parent51441e6460b505c07b4a8a6deeaa7de4bf6e8e33 (diff)
downloadgit-e9e8dd8801360e503db89be9372dc7ab719c4218.tar.gz
Merge branch 'jc/no-default-attr-tree-in-bare' into ps/undecided-is-not-necessarily-sha1
* jc/no-default-attr-tree-in-bare: stop using HEAD for attributes in bare repository by default
-rw-r--r--attr.c7
-rwxr-xr-xt/t0003-attributes.sh10
-rwxr-xr-xt/t5001-archive-attr.sh3
3 files changed, 10 insertions, 10 deletions
diff --git a/attr.c b/attr.c
index 679e42258c..6af7151088 100644
--- a/attr.c
+++ b/attr.c
@@ -1223,13 +1223,6 @@ static void compute_default_attr_source(struct object_id *attr_source)
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))
return;
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 774b52c298..d755cc3c29 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -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 &&
git init test &&
test_commit -C test gitattributes .gitattributes "f/path test=val" &&
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 &&
+ 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
'
diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh
index eaf959d8f6..7310774af5 100755
--- a/t/t5001-archive-attr.sh
+++ b/t/t5001-archive-attr.sh
@@ -133,7 +133,8 @@ test_expect_success 'git archive vs. 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
'