0

I was trying to clone Android Goldfish kernel source code by using the following command,

git clone https://android.googlesource.com/kernel/goldfish

but as it needed to download around 900MB of data I thought what the heck and went through with this one,

git clone https://android.googlesource.com/kernel/goldfish --branch android-goldfish-3.4 --depth 1

this reduced the download size to around 120MB and the downloading was done but with an error during unpacking objects.

Later when I used git status I saw a large number of files were deleted and they were shown as if they not even added and committed. I, foolishly, added them and committed them as new commit named 'local commit'.

git log --oneline
ca6ded2 Local Commit
2a51970 Merge branch 'android-3.4' into android-goldfish-3.4
c9cb2c8 UPSTREAM: netfilter: x_tables: fix unconditional helper
ac342b9 Merge branch 'android-3.4' into android-goldfish-3.4

Now after checking the files on remote, it became clear that the files which were shown deleted and which I committed are in the remote but not showing locally. So I tried to reset to previous commit. But these errors are shown:

git reset 2a51970
error: failed to read object b56d12bf5900c8f266132bc9b50dadfb092af10a at offset 26783674 from .git/objects/pack/pack-3ce58ac57f33a98f718e926caccca5ea5fa3a1fd.pack
fatal: packed object b56d12bf5900c8f266132bc9b50dadfb092af10a (stored in .git/objects/pack/pack-3ce58ac57f33a98f718e926caccca5ea5fa3a1fd.pack) is corrupt

fsck shows following:

git fsck
Checking object directories: 100% (256/256), done.
error: .git/objects/pack/pack-3ce58ac57f33a98f718e926caccca5ea5fa3a1fd.pack SHA1 checksum mismatch
error: index CRC mismatch for object b56d12bf5900c8f266132bc9b50dadfb092af10a from .git/objects/pack/pack-3ce58ac57f33a98f718e926caccca5ea5fa3a1fd.pack at offset 26783674
error: cannot unpack b56d12bf5900c8f266132bc9b50dadfb092af10a from .git/objects/pack/pack-3ce58ac57f33a98f718e926caccca5ea5fa3a1fd.pack at offset 26783674
error: index CRC mismatch for object 6149b476d9dffe06bcd1e3e3136bc335fd3dbf98 from .git/objects/pack/pack-3ce58ac57f33a98f718e926caccca5ea5fa3a1fd.pack at offset 27883077
error: inflate: data stream error (invalid distance too far back)
error: cannot unpack 6149b476d9dffe06bcd1e3e3136bc335fd3dbf98 from .git/objects/pack/pack-3ce58ac57f33a98f718e926caccca5ea5fa3a1fd.pack at offset 27883077
Checking objects: 100% (41134/41134), done.

My question: Is there a way to fix this without initiating the cloning process again. AND Was the cloning done properly or I did something wrong there?

Thank you.

Mohit
  • 1,045
  • 4
  • 18
  • 45

1 Answers1

0

It seems I found a way to fix this!

For all object corruption error relating to git, I think the best, hassle free, thing to do will be to make use of git-repair.

My procedure to Fix this (Ubuntu 16.04):

  1. Install git-repair

    sudo apt install git-repair

  2. Goto the local git repo directory

  3. Run git-repair

    git-repair

Thats it! All the corrupt objects were fixed(not going into technical details!) and the repo was in working condition.

Community
  • 1
  • 1
Mohit
  • 1,045
  • 4
  • 18
  • 45