diff -r -w -B -x .svn -x .git -I '$Id' -I '$Head' SvnWD GitWD
I’m verifying that the conversion from a Subversion source control repository to a Git repository hasn’t lost anything crucial. Since we’ve got multiple live branches, and at least the more recent of the versions tagged for production deployment are important, I need to do some fairly heavy testing that the contents of the repository match.Â (It’s nice to have the full history, and I think we do, but it’s not actually important.)
That one command looks at every file in two directory trees and compares the corresponding files in the two trees.
Except it skips directories named .svn and directories named .git (which will occur only on one side or the other), and ignores whitespace differences, and ignores the lines that Subversion is substituting keywords into, because Git doesn’t do that.
What’s good about this isn’t so much that the command-line interface is easy. But it’s easier to find what those switches do than what the entries in most dialog boxes do (there’s a much better culture of writing actual documentation in Unix and in the free software world). No, what’s good is that all those capabilities are already there, just waiting for me.
(Before applying the above, I have to use the appropriate “switch” command to have both working directories representing the branch or tag I want to verify. I could do that with command-lines, too. Then I could script the whole thing, with a list of branches and tags to compare. In fact, I could have it fetch the list of branches and tags live from the Subversion repository, so it was checking that everything really was identical. Maybe I should have gone that far; I did have to manually repeat the tests a second time when we had to change the final destination repository.)
There are in fact a few differences; mostly empty directories in Subversion that haven’t been copied to Git (6 of them). The more interesting question is, why is login.php in Subversion and not Git? Given that the copy in Subversion is clearly a test file, and doesn’t even contain actual php code, there’s not a problem here, but why wasn’t it copied over?