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

Re: [PATCH 1/2] pathattr: path based configuration of various attributes.

From
APAndy Parkins <andyparkins@gmail.com>
Date
Mar 1, 2007, 09:11 UTC
Message-ID
<200703010911.56048.andyparkins@gmail.com>
In-Reply-To
<7vps7txwie.fsf@assigned-by-dhcp.cox.net>
On Thursday 2007 March 01 07:18, Junio C Hamano wrote:
Show 5 quoted lines
> 	[pathattr "text/plain"]
>         	conv_i = crlf
> 		path = "*.txt"
>                 path = "*.c"
>                 path = "*.h"

Can I suggest that "crlf" is not the right name for something like this? What you actually want is to say

 conv_i = convert_from_local_lineendings
 conv_o = convert_to_local_lineendings

(Obviously I'm not really suggesting such long names). "crlf" implies that you want to convert to crlf endings /whatever/ the local line ending. Given that exactly the same .gitattributes would be in use on both windows and linux for the same repository, it's got to be an attribute name that makes sense in both cases. How about:

 conv_i = eol_to_lf
 conv_o = eol_to_local
I'm not sure about "conv" either.  "filter" would be more accurate.
 infilter = eol_to_lf
 outfilter = eol_to_local
--- Wild rantings start here, ignore at will ---
Also; for things like Ted's example of OpenDocument files, you might want
 infilter = gunzip
 outfilter = gzip
Then of course, order has to be significant:
 infilter = gunzip eol_to_lf
 outfilter = eol_to_local gzip

(That's probably a crazy thing to want to do, but it would make git spectacularly impressive). Here's another idea, what about making the filters configurable, with some builtin (and overridable)

[infilter "perfectpatch"]
  exec = hooks/perfectpatch
[infilter "codingstandards"]
  exec = scripts/check-for-spaces-in-the-wrong-place
[pathattr "text/c"]
  infilter = perfectpatch
  path = *.cc
  path = *.cpp
  path = *.c
  path = *.C
  path = *.h

We could also support a prettyfilter for getting your display example from patch 2/2 in the right place.

[prettyfilter]
  exec = display -
[pathattr "image/"]
  prettyfilter = rundisplay
  path = *.png

Which would be equally good for fixing line endings for display; prettyfilter could, I suppose, default to be the same as outfilter, which would be correct in most cases.

[pathattr "text/c"]
  prettyfilter = eol_to_local

Sorry for the long rambling email, it's very exciting this attribute stuff. I already love it.

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 3 in “pathattr: path based configuration of various attributes.”
  1. 1/2 pathattr: path based configuration of various attributes.Junio C Hamano, Mar 1, 2007
  2. Andy ParkinsMar 1, 2007
  3. Junio C HamanoMar 1, 2007

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.