Git blame on reorganized SVN repository

2019-05-28 14:37发布

问题:

git blame isn't showing me the all history of a SVN repository which had its layout reorganized.

I'm using git-svn to access a SVN repository. The SVN repository used to have a structure with a vast tree of folders to hold the many projects. Last year I reorganized and flattened the layout into a more standard trunk/tags/branches layout. The result of which is that all the files in the repository were moved on 17th May 2010.

Using the subclipse SVN client from Eclipse, I can do Team->Show Annotation and it shows the history of a file as I expect - lines of code changed in 2009 are correctly annoted with the author / date / checkin comment.

However, git blame on the git repository I've cloned using git-svn isn't so useful. For all lines of code modified before 17th May 2010, the annotation is: me / date 17th May 2010 / comment "reorganizing repository...".

I'm presuming the information is still there, is there way to get git blame to display it? I very speculatively tried git blame -C -C -C... without success.

回答1:

Are you sure the older commits appear in the git repo at all? Perhaps your svn reorganization was too big for git-svn to follow. Find the svn revision before the 17th May move, then git svn find-rev r12345 with that number to find the corresponding git hash, if there is one. Then git checkout that hash and see if the files you're interested in are in it.

If you told git-svn that your repo used the 'standard' trunk/branches/tags layout, it probably can't understand the other layout. You might need to redo the git-svn import in two stages: one for your old layout, and then again for your new layout. You can achieve this using the -r argument to git svn fetch to only fetch a given range of revisions.