git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: attr.c doesn't honor --work-tree option

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 6, 2014, 17:54 UTC
Message-ID
<xmqqvbwsyvn8.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAB7pA0_2kLJmRZb8Z_9+xOcrbwMZLgnZwC5f7etbE4OuJ1wgmA@mail.gmail.com>
Lasse Makholm <lasse.makholm@gmail.com> writes:
Show 13 quoted lines
> Here's a repro with -DDEBUG_ATTR=1 and a printf() in read_attr_from_file():
>
> $ cd /tmp/
> $ mkdir -p attr-test/repo
> $ cd attr-test/repo
> $ git init
> Initialized empty Git repository in /tmp/attr-test/repo/.git/
> $ echo 'dir/* filter=foo' >.gitattributes
> $
>
> Inside the working tree, it works:
>
> $ ~/src/git.git/git check-attr -a dir/file
Does check-ignore misbehave the same way?

I suspect that is this because check-attr is not a command that requires a working tree. The command was written primarily as a debugging aid that can be used anywhere as long as you have a repository to read strings from either its standard input or its arguments, and gives them directly to check_attr(), but it does so without first going to the top of the real working tree like check-ignore does.

Forcing it to go to the top of the working tree (see the attached one-liner, but note that I didn't test it) may give you want you want.

 git.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git.c b/git.c
index 7cf2953..314ec9f 100644
--- a/git.c
+++ b/git.c
@@ -342,7 +342,7 @@ static struct cmd_struct commands[] = {
 	{ "branch", cmd_branch, RUN_SETUP },
 	{ "bundle", cmd_bundle, RUN_SETUP_GENTLY },
 	{ "cat-file", cmd_cat_file, RUN_SETUP },
-	{ "check-attr", cmd_check_attr, RUN_SETUP },
+	{ "check-attr", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },
 	{ "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE },
 	{ "check-mailmap", cmd_check_mailmap, RUN_SETUP },
 	{ "check-ref-format", cmd_check_ref_format },
Previous: Lasse MakholmNext: Junio C Hamano
Message 2 of 13 in “attr.c doesn't honor --work-tree option”
  1. Lasse MakholmFeb 6, 2014
  2. Junio C HamanoFeb 6, 2014
  3. 1/2 t0003: do not chdir the whole test processJunio C Hamano, Feb 6, 2014
  4. 2/2 check-attr: move to the top of working tree when in non-bare repositoryJunio C Hamano, Feb 6, 2014
  5. Jonathan NiederFeb 6, 2014
  6. Jonathan NiederFeb 6, 2014
  7. Junio C HamanoFeb 6, 2014
  8. Michael HaggertyFeb 16, 2014
  9. Jonathan NiederFeb 6, 2014
  10. Junio C HamanoFeb 6, 2014
  11. Jonathan NiederFeb 6, 2014
  12. Junio C HamanoFeb 6, 2014
  13. Lasse MakholmFeb 10, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.