Re: [PATCH v3 1/2] attr: read attributes from HEAD when bare repo
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Oct 10, 2023, 19:58 UTC
- Message-ID
- <CAPig+cQHSiVbsNTDQWJZcyEA3uAHu5EzbCkd4CSJ7+Sno+Az-Q@mail.gmail.com>
- In-Reply-To
- <cef206d47c724f54220b0b915e5405b48f5eb2cb.1696967380.git.gitgitgadget@gmail.com>
On Tue, Oct 10, 2023 at 3:49 PM John Cai via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 20 quoted lines
> The motivation for 44451a2e5e (attr: teach "--attr-source=<tree>" global > option to "git" , 2023-05-06), was to make it possible to use > gitattributes with bare repositories. > > To make it easier to read gitattributes in bare repositories however, > let's just make HEAD:.gitattributes the default. This is in line with > how mailmap works, 8c473cecfd (mailmap: default mailmap.blob in bare > repositories, 2012-12-13). > > Signed-off-by: John Cai <johncai86@gmail.com> > --- > diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh > @@ -342,6 +342,20 @@ test_expect_success 'bare repository: check that .gitattribute is ignored' ' > +test_expect_success 'bare repo defaults to reading .gitattributes from HEAD' ' > + test_when_finished rm -rf test bare_with_gitattribute && > + git init test && > + ( > + cd test && > + test_commit gitattributes .gitattributes "f/path test=val" > + ) &&
Not at all worth a reroll, rather just for future reference... these days test_commit() supports -C, so the same could be accomplished without the subshell or `cd`:
test_commit -C test gitattributes .gitattributes "f/path test=val" &&
Show 5 quoted lines
> + git clone --bare test bare_with_gitattribute && > + echo "f/path: test: val" >expect && > + git -C bare_with_gitattribute check-attr test -- f/path >actual && > + test_cmp expect actual > +'