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

Re: [BUG] gitattribute macro expansion oddity

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Jan 11, 2012, 04:37 UTC
Message-ID
<4F0D1227.5020509@alum.mit.edu>
In-Reply-To
<7v1ur7bhhe.fsf@alter.siamese.dyndns.org>
On 01/10/2012 06:22 PM, Junio C Hamano wrote:
Show 20 quoted lines
> Regardless of this unrelated regression, after looking at what ec775c4
> wanted to do again, I am very much tempted to just revert it.
> 
> It aimed to take these three
> 
>         *       ident
>         foo     mybin
>         bar     mybin ident
> 
> and wanted to omit 'ident' from "foo" when there is this macro definition
> elsewhere:
> 
> 	[attr] mybin binary -ident
> 
> But the real point of the macro was that the users do not have to know
> their internals, iow, if you explicitly specify a pattern that overrides
> the contents of the macro, that explicit pattern should win. When deciding
> the value of "ident" attribute for path "foo", "* ident" is stronger than
> "foo mybin" (the latter of which does not say anything about 'ident'
> explicitly).

I like the simplicity of the rule "apply attributes in the order found in the .gitattributes files" better than the rule you are proposing, which seems like it will become more complicated to explain.

For example, it would seem under your rule for the above example that the "mybin" macro should bestow on file foo the "binary" attribute and also the "mybin" attribute (given that macros are themselves attributes), but not "-ident".

You would also have to decide and explain whether a macro that invokes a macro that sets or clears attribute "foo" is "weaker" than a simple macro that clears or sets attribute "foo".

I have one real-life use case that would become more difficult with your rule:

# Marker for textlike files whose EOL characters haven't been # normalized yet: [attr]eol-fixme -text !eol

*.cc text eol=lf

# Then later, perhaps in some subdirectory's .gitattributes: SomeParticularScrewedUpFile.cc eol-fixme

The point of the eol-fixme macro is (1) to prevent git from throwing a tantrum and (2) to mark the file as needing cleanup sometime in the future.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Junio C Hamano
Message 13 of 13 in “[BUG] gitattribute macro expansion oddity”
  1. Jeff KingJan 10, 2012
  2. Michael HaggertyJan 10, 2012
  3. Jeff KingJan 10, 2012
  4. attr: don't confuse prefixes with leading directoriesJeff King, Jan 10, 2012
  5. Jeff KingJan 10, 2012
  6. Junio C HamanoJan 10, 2012
  7. Jeff KingJan 10, 2012
  8. Jeff KingJan 10, 2012
  9. Junio C HamanoJan 10, 2012
  10. Jeff KingJan 10, 2012
  11. Junio C HamanoJan 10, 2012
  12. Junio C HamanoJan 10, 2012
  13. Michael HaggertyJan 11, 2012

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.