Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

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

From: Andy Parkins <hidden>
Date: 2016-06-15 22:42:57

On Thursday 2007 March 01 07:18, Junio C Hamano wrote:
	[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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help