Remember a git_gerrit file damage error troubleshooting

One day, an error occurred when pulling the code

Checking object directories: 100% (256/256), done.
error: ./objects/pack/pack-e434848729a1a52d7ec5cd39ade4fac7f7aa5595.pack SHA1 checksum mismatch
error: index CRC mismatch for object 582bda543520dcbde0f6baaae86d5f9b0626787 /pack/pack-e434848729a1a52d7ec5cd39ade4fac7f7aa5595.pack at offset 57938241
error: inflate: data stream error (invalid distances set)

General idea Google to see if there is a similar solution, and found a useful article:
http://web.mit. edu/jhawk/mnt/spo/git/git-doc/howto/recover-corrupted-object-harder.html
has a corresponding translation, but the translation is a bit twisted, I don't know if the machine translation has simply revised it by human
http:/ /blog.jobbole.com/50108/ The

general idea is to exhaustively change every byte in the wrong place so that it can be decompressed. Unfortunately, this thing does not apply to my situation after the experiment, because the author just made a wrong word stanza, and I finally fixed it and found that it was 9 bytes wrong and scattered in various places.

I bypassed many detours in the middle, pulled down the git source code, modified the unpacked source code, and then compiled the block that adjusted the error, but in the end, my case repair can bypass many detours, that is, my wrong sha1 object can be complete print it out.
That is,
git cat-file -p 582bda543520dcbde0f6baaae86d5f9b626787f0 
can get this object, and then everything is simple, cat this file out, put it in a new git warehouse, then add it in and gc, use the dd command to down the packaged offset from the pack file Down, cover the wrong place as it is and it will be solved.

What is unclear at present is why the wrong can still be cat out correctly, if the cat can't come out, it can only use the unpacking method to deal with this.

Git is so powerful, there should be related low level commands that can be handled without involving the source code modification. The real reason has not been studied yet. When it is empty, I will check the root cause and record it temporarily for reference.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326647033&siteId=291194637