5 ms·
> Why can't our source control software take code indented any way, any how, and convert it to your personal preference when you pull the repo? It's not like we
by tadfisher 11y ago
> Why can't our source control software take code indented any way, any how, and convert it to your personal preference when you pull the repo? It's not like we enforce what color syntax highlighting you use or what font.
Because the mapping from one whitespace style to another is not a bijection. Moreover, our source control tools rely on things like content hashes which change when even a single bit of the source has changed, and sometimes even our language parsers depend on whitespace format.
Frustrating, I know, but you will not see a resolution to this problem with automated tools alone. You will, however, when the Tab key is removed from keyboards altogether :)
- ks 11y agoWouldn't this feature be similar to how Git converts line endings? https://help.github.com/articles/dealing-with-line-endings/ https://help.github.com/articles/dealing-with-line-endings/ It would probably have to be configured per repo so that it doesn't mess with tab delimited files etc.
- MichaelGG 11y agoAuto CrLf is a terrible thing that can change the meaning of programs. Source control shouldn't be changing the contents of files (though a hook to format wouldn't be bad necessarily).
- threatofrain 11y agoI believe mapping is 1:1 when only the initial indentation is used with tab/space, and further indentation is done with spaces.
- freshhawk 11y agoBut I have seen a solution to this problem, back in subversion days. With help from perl-tidy and php-tidy. Pre commit hooks, combined with an appropriate *-tidy program for your language. Code is formatted according to the repo tidy config with a pre-commit hook and formatted according to the developers preference on checkout. I'm missing why whitespace style mapping is not a bijection, you do have to accept some limits to code style in terms of completely rigid indentation rules, and it is obviously language specific. But it seems to be a bijection to me, what am I missing?