3

I'm trying to tidy up my code, so i'd like to always run astyle on the needed files before doing a commit. I've seen answers mentioning a pre-commit hook, and using gitattributes, but they both commit the file contents as they were BEFORE running astyle. So, after the commit, the file is shown as being modified again..

Only the next commit will actually commit the modified file.

I've tried this approach :

cat .gitattributes 
*.cpp   filter=code_style

cat .git/config
[filter "code_style"]
clean = astyle --style=whitesmith %f
smudge = cat

and basically when i do the commit, the file is commited with the wrong indentation, and is shown as modified, with the right indentation. I tried with the pre-commit hook, and the same thing happens.

Is it even possible to do what i want? thanks.

Joao Pincho
  • 939
  • 2
  • 11
  • 26

0 Answers0