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

Re: Surprising interaction of "binary" and "eol" gitattributes

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Mar 10, 2015, 22:24 UTC
Message-ID
<54FF6F1B.2030900@alum.mit.edu>
In-Reply-To
<54FF5376.7070500@web.de>
On 03/10/2015 09:26 PM, Torsten Bögershausen wrote:
Show 22 quoted lines
> On 10.03.15 20:25, Michael Haggerty wrote:
>> [...]
>> I'm still trying to infer the spirit of the current behavior, so caveats
>> here.
>>
>> This comes from a real-life scenario where a user, somewhere early in
>> .gitattributes, had
>>
>>     * text
>>     * eol=crlf
>>
>> and then later (this could be in a subdirectory) tried to carve out
>> exceptions to this rule by using
>>
>>     *.png binary
>>     * text=auto
> Hm,
> I can see 2 problems here:
> the "binary" attribute does not exist at all.
>
> I sometimes which we had it, but we don't.
> There is "text" and "-text", and that is it.

There is a "binary" macro that is equivalent to "-diff -merge -text". It is documented in gitattributes(5) under "USING MACRO ATTRIBUTES" and "DEFINING MACRO ATTRIBUTES".

Show 16 quoted lines
> The other problem is the order of the lines, which is fully
> intuitive for each person who has ever written a "matching parser".
> 
> The parser matches each file namr on it's own, depending on the matching:
> 
> *.png -text
> * text=auto
> means that all png files are binary, and ALL files are "auto".
> 
> Guess what happens to the png's ?
> 
> The second rule wins, as it is the last rule processed.
> 
> git check-attr text *
> A.png: text: auto
> B.txt: text: auto

That much is perfectly clear. The question is, what should happen when the contents-based heuristic, whose use was requested by "text=auto", determines that A.png is in fact a binary file? Should it be subjected to EOL translation anyway? I think not.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
Previous: Torsten Bögershausen
Message 17 of 17 in “Surprising interaction of "binary" and "eol" gitattributes”
  1. Michael HaggertyMar 5, 2015
  2. Torsten BögershausenMar 5, 2015
  3. Junio C HamanoMar 5, 2015
  4. Torsten BögershausenMar 6, 2015
  5. Michael HaggertyMar 6, 2015
  6. Torsten BögershausenMar 6, 2015
  7. Michael HaggertyMar 10, 2015
  8. Junio C HamanoMar 10, 2015
  9. Michael HaggertyMar 10, 2015
  10. Junio C HamanoMar 10, 2015
  11. Torsten BögershausenMar 11, 2015
  12. Junio C HamanoMar 11, 2015
  13. Johannes SixtMar 11, 2015
  14. Junio C HamanoMar 11, 2015
  15. Junio C HamanoMar 11, 2015
  16. Torsten BögershausenMar 10, 2015
  17. Michael HaggertyMar 10, 2015

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.