+4  A: 

I don't know how best to deal with some of the more invasive changes you're describing, but...

The -w option to git blame, git diff, and others causes git to ignore changes in whitespace, so you can more easily see the real differences.

Phil
And `-M` / `-C` options to `git diff` and `git blame` make it follow renames and copies; in the case of `git blame` also moving and copying of fragments of code across files.
Jakub Narębski
Ooh thanks, I've just been annoyed by this for a while in one of my projects. Also, I feel bad for upvoting you since you had 1337 rep :/
Ibrahim
+3  A: 

I would recommend making those evolutions one step at a time, in a central Git repo (central as in "public reference for all other repositories to follow):

  • indentation
  • then reordering methods
  • then renaming
  • then ...

But not "indentation-reordering-renaming-...-one giant commit".

That way, you give to Git a reasonable chance to follow the changes across refactoring modifications.

Plus, I would not accept any new merge (pulled from other repo) which do not have applied the same refactoring before pushing their code.
If applying the format process brings any changes to the fetched code, you could reject it and ask for the remote repo to conform to the new standards first (at least by pulling from your repo before making any more push).

VonC
We've been leaning that way too. As for not accepting patches unless their rebased against the post-transform code, that isn't really a viable option; "rebasing" across such a change would amount to manually most/all retyping the changes (think how the inevitable merge would go if most lines had been changed).So we considered making them run the refactor tool themselves, but since this process could be automated why not run it ourselves on patch acceptance rather than making them learn it, and adding an extra hurdle on contributions?
MarkusQ
@MarkusQ: I agree on the principle, but just to be sure: I wasn't talking about a mandatory "rebase" to be done on the client side, only about a mandatory "reformat" to be done by the client before his push (reformat checked in a hook on the server side by re-applying the same reformat and checking the result is the same than the file received). That will avoid many merge conflicts when those same clients fetch the central public repo changes and rebase their work on top of it.
VonC
A: 

You will also need a mergetool that allows agressive ignoring of whitespace. p4merge does this, and is freely downloadable.

krosenvold
Thanks for the downvote; I'd be curious to know why ?
krosenvold
Probably because the question is about git and how it will handle the changes, and not necessarily other tools to for helping with the work.
hlovdal