Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

standards - git: change styling (whitespace) without changing ownership/blame?

We have a massive, ancient codebase that needs a lot of cleanup. We have always had coding standards and everyone has always tried to follow them, but they were not enforced so over time a lot of violations have creeped in. Many of them are just whitespace issues, like using tabs instead of spaces, or spaces where there shouldn't be any, or missing spaces where they should be. We are going to start actively enforcing our coding standards to make sure more violations don't creep in, but it's difficult to enforce them in an automated way on only the changes, so it would be nice to clean up these old files.

There are tools that can automate fixing these issues, however if I do that then blame is going to show me as the owner of those lines, when in reality I may never have even seen them. I know there is a setting to make blame ignore whitespace changes, but I can't make everyone use blame the same way, including other visual tools and things like gitstats. In an ideal world there would be some way to rewrite history to look like the violations were never introduced, without covering up who introduced the actual code, but I can't find anything like that.

question from:https://stackoverflow.com/questions/4112410/git-change-styling-whitespace-without-changing-ownership-blame

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you are trying to get a Root Cause issue using blame, don't forget use the -w flag to ignore all the white-spaces or indentation changes. So you'll get the last real change to the code, instead just an indentation, or removing trailing spaces.

git blame -w app/to/file.rb

or you can just use, git slap command..

git config alias.slap "blame -w";
git slap app/path/to/file.rb

having same results :D


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...