[Insight-developers] make git automatically convert tabs to spaces
Mark Roden
mmroden at gmail.com
Tue Aug 31 11:21:18 EDT 2010
Hi all,
I learned a neat trick for the tabs/spaces issue I was having earlier.
Turns out Git can be set to scrub all files that go to the repository to
behave by a set of rules, as per this question here:
http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs
So, on my mac, I did these things:
1) edit .git/info/attributes to be:
*.cxx filter=tabspace
*.txx filter=tabspace
*.h filter=tabspace
*.c filter=tabspace
2) set the tabspace filter to be:
git config --global filter.tabspace.clean 'expand -t 2 '
(this is the mac/bsd version of the command; the version on that SO question
is for a different Linux flavor, I believe)
3) Now when you commit, your tabs will be automatically converted to 2
spaces, thus avoiding that pre-commit hook check.
Potential trouble situations: some characters cause the expand program to
fail. When piped to 'less', the results are failing at what looks like <BF>
in the command line and an o with a vertical slash through it in XCode. I
think that expand will only work on char streams, not unicode streams, so so
long as our code is submitted as purely 8-bit chars, this will work.
Hope that helps,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20100831/f63902cc/attachment.htm>
More information about the Insight-developers
mailing list