On Wed, 5 Feb 2014 05:51:38 -0800 (PST)
Philipp Kraus <philipp.kr...@flashpixx.de> wrote:

> can I use gitattributes for change the encoding of text file? I would
> like to encode all text file with UTF-8 and replace the \t to 4
> spaces. How can I do this?

Well, in theory, you can -- using the so-called "clean filter" (see the
relevant section of the gitattributes manual page), -- but why should

For instance, how do you know the *input* encoding to be used when
re-encoding?  If it's supposed to be the system encoding (and thus it
appears you're using Windows as all sensible POSIX system use UTF-8
by default since ages, or run with encoding-agnostic defaults such as
the "C" locale) then why not just use UTF-8?  Any sensible text editor
these days supports it.  It might require certain tweaking but writing
a Git filter is way more pain in the neck.  The same goes about
indentation--why not just use a specialized tool, like indent [1], for
fixing up the formatting?  Or, if IDE is used, just enforce this in its
editor's settings?

As one example, to develop in Go on Windows, I have the following
tweaks in my ~/_vimrc file:

  if has("autocmd")
    autocmd FileType go setlocal makeprg=go\ build
    autocmd BufNewFile *.go setlocal ff=unix|setlocal fenc=utf-8|setlocal nobomb

This forces LF-style line endings, UTF-8 for the file encoding and
forces deleting of byte-order-marks on save.

Another "problem" is that while it's okay to keep the .gitattributes
file in the repository (committed), the filter program is supposed to
be located on each developer's machine.

1. http://www.gnu.org/software/indent/

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to