In order to clean our code we want to use astyle. The matter is that we want someone to do the job, but blaming previous committer (real author of the code and not the one who cleans).
Is there a way to do it safely in git ?
In order to clean our code we want to use astyle. The matter is that we want someone to do the job, but blaming previous committer (real author of the code and not the one who cleans).
Is there a way to do it safely in git ?
The problem is when you clearly think about it. You let one people change your code but you can't see that this was that people during the cleanup. That would be very stupid.
So in my mind you shouldn't do that. Let that person change the code with a normal commit.
What you can do is you can set the author during the commit.
git checkout master
git merge my_branch
git commit --amend --author="Your name <my.adress@email.com>"
git push origin master
Or set it directly on commit.
git commit --author="Your name <my.adress@email.com>" ....
But i think thats not the best way.
Edit: There is a very intelligent phrase Don't fight the framework.
There are at least two ways to deal with the situation.
git blame
What you cannot do is to have a "transparent commit" that would be totally ignored by git blame
. But you can ask git blame
to ignore whitespace changes with git blame -w
. Nothing to do at the time you do the code reformat.
The other option is to rewrite history, so that the new history looks like the code was correctly formatted by the time it was committed. Note that history rewriting is a dangerous operation, you should use this only if you fully understand the consequences of doing it.
You can do a batch rewrite using git rebase -i --exec
.