Right now I am in the process of following this tutorial to auto-convert spaces to tabs:
https://sites.google.com/site/gibekm/programming/git/converting-between-tabs-and-spaces I would like to automate step 3 so it could be placed in a repository creation batch file like CreateAdvancedRepo.sh or so... So my question is how to place a text string like: " *.<extension> filter=tabspace2" into a new file and new directory like so: .git/info/attributes >From experimenting and googling best way to do this seems to be: new@new-PC MINGW64 /e/SourceCode/PascalCoinGit/PascalCoin (PascalCoinMaster) mkdir NewFolder new@new-PC MINGW64 /e/SourceCode/PascalCoinGit/PascalCoin (PascalCoinMaster) echo "this is a line" > newfolder/file.txt However echo can be tricky and might not do the more complex command above going to give it a try: new@new-PC MINGW64 /e/SourceCode/PascalCoinGit/PascalCoin (PascalCoinMaster) echo " *.<extension> filter=tabspace2" > newfolder/test.txt OK So far so good, problem seems solved for now ! ;) =D Going to give this auto conversion a try soon... I see one little potential problem with this method, maybe the attributes file already existed, but in new repo problably not... Perhaps: echo "this is a line" >> newfolder/file2.txt Might be more safe. OK All seem to have worked and puts this line in a text file: *.<extension> filter=tabspace2 Tutorial text from link above: " It is very easy to convert between tabs and spaces automatically when committing and check-outing text files with GIT. GIT allows it with the attributes mechanism: http://git-scm.com/book/ch7-2.html <http://www.google.com/url?q=http%3A%2F%2Fgit-scm.com%2Fbook%2Fch7-2.html&sa=D&sntz=1&usg=AFQjCNEGLhRRDjjOBsAnu7JNXKtfLWA6NA> http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs <http://www.google.com/url?q=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F2316677%2Fcan-git-automatically-switch-between-spaces-and-tabs&sa=D&sntz=1&usg=AFQjCNER2-v0Pciz8I11GO_5qvgdSEmQ8Q> To configure this behavior all you need is: 1. Place 'expand' and 'unexpand' commands in your 'PATH' environment variable. For Windows they are part of GnuWin32 CoreUtils package: 1. http://gnuwin32.sourceforge.net/packages.html <http://www.google.com/url?q=http%3A%2F%2Fgnuwin32.sourceforge.net%2Fpackages.html&sa=D&sntz=1&usg=AFQjCNHmiTo0Ezii9wTTmIfklDBkoqiswg> 2. Define needed GIT filter names. These are examples if you want tabs locally and two or four spaces in the repository: 1. git config --system filter.tabspace2.clean "expand --tabs=2 --initial" 2. git config --system filter.tabspace2.smudge "unexpand --tabs=2 --first-only" 3. git config --system filter.tabspace4.clean "expand --tabs=4 --initial" 4. git config --system filter.tabspace4.smudge "unexpand --tabs=4 --first-only" 3. Apply settings to your local repository. 1. Create .git/info/attributes file inside your local repository directory and add following line(s) to it: 1. *.<extension> filter=tabspace2 2. Where <extension> is file extension than will be filtered. 4. If you have any changes, commit them and then checkout all files to have filtered version on a disc: 1. git checkout HEAD -- ** Nemerle Things may be a little more complicated when you want to do the same with Nemerle source codes, because there is a risk that 'unexpand' command can corrupt files that are using indentation-based syntax. The solution is to use script that expands/unexpands only files with non indentation-based syntax. You can copy tabs_nemerle.sh script to the bin directory of git and configure filters that way: git config --system filter.tabspace2.clean "tabs_nemerle.sh 2 expand"git config --system filter.tabspace2.smudge "tabs_nemerle.sh 2 unexpand" " Bye, Skybuck. (Somehow my e-mail is screwed up but ok) -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/342137bb-a47f-4b33-bbc2-e6e2f77f6edbn%40googlegroups.com.
