Situation
In the version controlled project I'm currently working I wanted to use tabs, but the standard is to use four spaces. I managed to resolve that with this answer and this page:
https://stackoverflow.com/a/2318063/7398644
https://sites.google.com/site/gibekm/programming/git/converting-between-tabs-and-spaces
The problem now is that some sections of code in the repository are actually committed with tabs since before. This is problematic since git now expands all leading tabs into spaces before diffing against the repository and will thus say that there's a difference regardless of what I do. As I'm sure you know, it's bad form to commit lines of code with just whitespace changes.
I'm using Git with SourceTree, which' diff view can be set to ignore whitespace changes, but even if no changes are shown it still lists the file as modified (I'm assuming it's because the hash is different). I would like to have a clean staging area that isn't cluttered by unmodified files. I also fear that it could cause merge conflicts in the future.
Question
Is there any way to not expand (alternatively unexpand after expanding) the tabs that are also tabs in the repository?
Findings
I could replace expand
with a script of my own, but it would need to do things that I don't know how to do. I found this excellent information that I couldn't even manage to find in the Git documentation:
https://github.com/gilesbowkett/git-smudge-and-clean
Apparently the script would work by reading stdin and writing to stdout. That means that I have no idea of what file is being processed. I would also need to have access to the version on the repository in order to compare the lines, which I would have no way of doing if I don't even know what file to check. The best I can think of is to ask Git what files are changed and try to compare those files to the input from stdin to find the closest match.