Re: [git-users] change encoding and text replace
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 you? 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 endif 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.
Re: [git-users] change encoding and text replace
Hello, thanks for your answer. Am Mittwoch, 5. Februar 2014 15:29:14 UTC+1 schrieb Konstantin Khomoutov: 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. It is more a social problem and I don't want to fix encoding errors manually. Mostly user does not configurate their editors correct and I get after a commit encoding errors within the files, so I would like to convert it automatically by git, in a best view OS independed. Thanks a lot Phil -- 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.
Re: [git-users] change encoding and text replace
On Wednesday, February 5, 2014 9:59:30 AM UTC-5, Philipp Kraus wrote: It is more a social problem and I don't want to fix encoding errors manually. Mostly user does not configurate their editors correct and I get after a commit encoding errors within the files, so I would like to convert it automatically by git, in a best view OS independed. For social issues, just reject the commit? -- 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.
Re: [git-users] change encoding and text replace
Am Mittwoch, 5. Februar 2014 21:55:30 UTC+1 schrieb Huu Da Tran: On Wednesday, February 5, 2014 9:59:30 AM UTC-5, Philipp Kraus wrote: It is more a social problem and I don't want to fix encoding errors manually. Mostly user does not configurate their editors correct and I get after a commit encoding errors within the files, so I would like to convert it automatically by git, in a best view OS independed. For social issues, just reject the commit? Okay, so you would like to create a pre-push hook and check the file encoding? Phil -- 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.
Re: [git-users] change encoding and text replace
On Wed, 5 Feb 2014 13:39:47 -0800 (PST) Philipp Kraus philipp.kr...@flashpixx.de wrote: It is more a social problem and I don't want to fix encoding errors manually. Mostly user does not configurate their editors correct and I get after a commit encoding errors within the files, so I would like to convert it automatically by git, in a best view OS independed. For social issues, just reject the commit? Okay, so you would like to create a pre-push hook and check the file encoding? Actually, I like this approach more than clean filters, but on the other hand, when pondering Git workflows, it helps to think about what demigods do. For instance, Linux kernel folks do not have sanity checking hooks on their many many rendez-vouz repositories--but folks asking for pull requests or submitting patches are supposed to ensure this code is properly formatted *and* the leutenants who accept and integrate their code are supposed to check the changes. So one way to solve your social problem is to have your devs not commit on blessed branches but rather to their own feature branches; then someone would just perlustrate the code and if everything okay, merge it into one of the blessed branches, otherwise the code would be rejected and its dev asked to fix it and force-push their changes again for review. An alternative approach is to have mandatory code review using a tool like Gerrit. I think you might find [1] enlightening in some ways. Not that you should adopt this methodology exactly, but look how they go about constant pushes to development branches and active reviewing of this code with sign-offs. 1. http://scottchacon.com/2011/08/31/github-flow.html -- 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.