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

Re: gitattributes don't work

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Jan 3, 2011, 04:34 UTC
Message-ID
<AANLkTikbGQkREQAx0p6Q+DrXPP2zWDU7doOO6yg+NGeC@mail.gmail.com>
In-Reply-To
<ifr610$3kl$1@dough.gmane.org>
2011/1/3 Marcin Wiśnicki <mwisnicki@gmail.com>:
Show 16 quoted lines
> I'm trying to exclude certain paths (those that contain "xmac/gen/") from
> diff output using .git/info/attributes (not .gitattributes).
>
> According to gitattributes(5) it supports patterns from gitignore(5).
>
> Example path that must be excluded:
> src/byucc/jhdl/CSRC/xmac/gen/and2_dp_g.xmac
>
> What I've tried but didn't work:
> xmac/gen/ -diff
>
> Following works but is not what I want:
> *.xmac -diff
>
> It seems I can only get it to work for file names but not for whole paths.
> What am I doing wrong or is this a bug ?

While gitattributes(5) says that, actually gitattributes and gitignore use different matching implementations. gitattributes one seems unchanged since its introduction in d0bfd02 (Add basic infrastructure to assign attributes to paths - 2007-04-12). gitignore on the other hand learned foo/ pattern later in d6b8fc3 (gitignore(5): Allow "foo/" in ignore list to match directory "foo" - 2008-01-31).

Yeah, it looks like a bug to me. A better way to solve this once and for all, is to unify the two implementations (which is good for gitattr because there have been optimizations added to gitignore). I tried long ago and gave up. Something to do with the order of matching (gitignore tries inner directories first, while gitattr starts from outer ones).

For the time being, anyone who changes gitignore should be reminded to consider whether it's applicable to gitattributes and vice versa.

Which reminds me, Joshua, maybe you should add case-insensitive support to gitattributes too ;-)

-- 
Duy
Previous: Jonathan NiederNext: Marcin Wiśnicki
Message 3 of 5 in “gitattributes don't work”
  1. Marcin WiśnickiJan 3, 2011
  2. Jonathan NiederJan 3, 2011
  3. Nguyen Thai Ngoc DuyJan 3, 2011
  4. Marcin WiśnickiJan 4, 2011
  5. Junio C HamanoJan 4, 2011

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.