8

I have worked with and successfully compiled and installed AOSP about a year or two ago. I'm trying to get back up and running in it to do some development. However, I keep getting this error:

    Fetching projects: 100% (486/486), done.  
Traceback (most recent call last):
  File "/home/hoshi/WORKING_DIRECTORY/.repo/repo/main.py", line 500, in <module>
    _Main(sys.argv[1:])
  File "/home/hoshi/WORKING_DIRECTORY/.repo/repo/main.py", line 476, in _Main
    result = repo._Run(argv) or 0
  File "/home/hoshi/WORKING_DIRECTORY/.repo/repo/main.py", line 155, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/hoshi/WORKING_DIRECTORY/.repo/repo/subcmds/sync.py", line 675, in Execute
    project.Sync_LocalHalf(syncbuf)
  File "/home/hoshi/WORKING_DIRECTORY/.repo/repo/project.py", line 1204, in Sync_LocalHalf
    lost = self._revlist(not_rev(revid), HEAD)
  File "/home/hoshi/WORKING_DIRECTORY/.repo/repo/project.py", line 2241, in _revlist
    return self.work_git.rev_list(*a, **kw)
  File "/home/hoshi/WORKING_DIRECTORY/.repo/repo/project.py", line 2435, in rev_list
    p.stderr))
error.GitError: device/lge/mako-kernel rev-list ('^7bf237bdf8a8c6d516219dc09b3bc114aa0e863d', 'HEAD', '--'): fatal: bad object HEAD

This occurs after successfully "fetching all the packages" (first line of above terminal output). I've tried deleting the .repo folder in WORKING_DIRECTORY and re-initializing repo there. I thought it fixed the issue, but got the error again after probably a couple hours of syncing! I've tried several solutions from various discussions/forums and can't seem to figure it out.

Any help finding a solution would be much appreciated!

jdods
  • 323
  • 7
  • 18

3 Answers3

12

I know the question was posted over a year ago but this answer will hopefully help others. Plus it's frustrating when this happens as the fetching can take many minutes before you know the error still exists or is finally resolved.

The solution is to purge the .git folders for the associated project named in the error message (in this case it was lge/mako-kernel)

$ rm -rf .repo/project-objects/device/lge/mako-kernel.git
$ rm -rf .repo/projects/device/lge/mako-kernel.git
$ rm -rf device/lge/mako-kernel/.git

Note if don't delete all three of the folders, the tree status will be inconsistent and the same error will occur.

This was also reported in multiple projects so I applied this iteratively until the whole sync was successful.

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
dr_g
  • 1,179
  • 7
  • 10
  • This does not work if the `manifest/.git` is the problem. `error: in `sync`: [Errno 2] No such file or directory: '/home/jan/src/android/neo-los13/.repo/manifests/.git/HEAD' error: manifest missing or unreadable -- please run init` There is no manifest in projects and project-objects. – JPT Sep 11 '17 at 07:18
  • 2
    Well. That was painful. For feature readers, this is caused by the commits on HEAD being rebased away in the new version of AOSP you're trying to grab. – RubberDuck Feb 28 '18 at 13:26
  • I can't recall if this actually fixed my error, but I'm going to mark it as the solution. I think I did actually get it fixed, but it's been a while and don't actually recall completely. – jdods Feb 28 '18 at 21:33
  • This is no solution, you are suggesting to just delete everything and redownload. – Nobody Apr 25 '18 at 10:53
  • 3
    @JPT In my case also, .repo/manifests was the problem: error.GitError: manifests rev-list (u'^988591c2604701096c0f86dd695ff5d4ed6b7c88', 'HEAD', '--'): fatal: bad revision 'HEAD'. Solution was rm -rf .repo/manifests/.git and then repo init. – Padmanabha V Jul 08 '20 at 07:48
0

In my case, "manifests" was a problem.

error.GitError: manifests rev-list ('^HEAD', u'a0383f844a8176c76d3cc47d717dacd93e5ba529', '--'): fatal: bad revision '^HEAD

And I resolved by removing this folder.

rm -rf .repo/manifests/.git/

0

The answer by @dr_g worked for me.

As a supplement to that solution I use the following script snippet to cleanup a bunch of failing GIT repositories in one go. Edit the entries in the array arr as per your requirements.

declare -a arr=(
   "platform/external/ImageMagick" 
   "platform/external/curl"
   "platform/external/deqp"
)

for i in "${arr[@]}"
do
   echo "Cleaning ${i} ..."
   rm -rf .repo/project-objects/${i}.git
   rm -rf .repo/projects/${i}.git
   rm -rf ${i}/.git
done
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Dhwani Katagade
  • 939
  • 11
  • 22