How do I resolve a git-svn index mismatch?

亡梦爱人 提交于 2019-11-30 06:37:01

问题


When I did a git svn rebase it stopped at one point saying:

Index mismatch: SHA key of a tree != SHA key of another tree. (I come to know that these SHA keys corresponds to a tree and not a commit from git show of the above two sha keys.)

re-reading <sha index of a commit in svn/trunk>
... list of files ...
fatal: bad object <SHA1 index of the bad object>
rev-list -1 <SHA1 index of the bad object> --not <SHA1 index of the revision it was trying to re-read>: command returned error: 128

I am not very experienced in the internal workings of git, so is there a sequence of steps to follow to dissect problems like these and possibly resolve them?


回答1:


I've had this error twice and both times resolved it by removing the svn folder inside the .git folder.

rm -r .git/svn

then rebuild the svn metadata with:

git svn fetch

You will probably see a message along the lines of:

Migrating from a git-svn v1 layout...
Data from a previous version of git-svn exists, but
    .git/svn
    (required for this version (1.7.0.4) of git-svn) does not exist.
Done migrating from a git-svn v1 layout

and after while (rebuilding can take a while especially on large repositories) you should end up with a working mirror of the svn repository again.




回答2:


Please don't remove the .git/svn folder to fix this. It requires you to rebuild everything, it is annoying, it will take awhile (for the size of my repo several hours) and it is NOT NECESSARY.

I found the right answer here and I've included it below.

From the link:

Inside the .git directory run the following:

$ find . -exec grep -Hin 5b32d4ac2e03a566830f30a702523c68dbdf715b {} \;
Binary file ./svn/.caches/lookup_svn_merge.db matches
Binary file ./svn/.caches/check_cherry_pick.db matches

Now delete the matching .svn/.caches from the output of the first command

$ rm ./svn/.caches/lookup_svn_merge.db
$ rm ./svn/.caches/check_cherry_pick.db

Now git svn rebase or git svn fetch to your heart's content.




回答3:


Update git client and refetch last svn commits using:

git svn reset -r 12345
git svn rebase

where 12345 is existing svn revision.




回答4:


In my case, the issue was caused by a new/unknown svn author who was not in my authors file that git-svn was configured to use. It reported it in the output that that I ignored the first few reads:

Index mismatch: <leftsha1> != <rightsha1>
rereading <anothersha1>
        ... list of files ...
Author: <name> not defined in /path/to/authors file

So that gave me the name that I was missing, and what file to add it too (I pulled the email from my organizations user registry) and was smooth sailing.




回答5:


The problem there is that you have to do this systematically in this case :

  • use git + svn
  • create branch on svn with git-svn
  • merge branch to trunk with svn tools
  • remove the svn branch
  • do a git-svn rebase

Something missing, everything crash. The only way I know to recover is do remove all svn in .git and rebuild everything. It's just annoying and take a while !




回答6:


I just had this error myself. Just delete the ref, like so:

rm .git/refs/remotes/git-svn

That should clear up the error.




回答7:


Maybe something to do with Copy-On-Write feature of your filesystem (ext4/btrfs/etc...) ?

See : https://stackoverflow.com/a/42299634/7491491




回答8:


I got this error:

Index mismatch: <sha> != <sha> re-reading <sha index of a commit in svn/trunk> ... list of files ... <path> was not found in commit <sha> (r<svn rev>)

Looking in SVN repo at the history of the reported path, I found the SVN revision where the file had been added. But looking in Git at the commit created for that revision I found that it didn't contain any files!

I think this had been caused by a full disk earlier. After doing a git svn reset -r back to the revision of the broken Git commit, git svn fetch worked fine again.




回答9:


I ran into this during the initial cloning turns out someone created a branch called trunk which conflicted with the real trunk. After ignoring /branches/trunk all worked




回答10:


Likely, you may also have Checksum mismatch at the same time in your message:

I found solution here Git svn rebase : checksum mismatch:

git svn log <item with checksum mismatch>
git svn reset -r<top history revision in the log> -p
git svn rebase


来源:https://stackoverflow.com/questions/4073956/how-do-i-resolve-a-git-svn-index-mismatch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!