AOSP repo sync error, bad object HEAD
Asked Answered
I

4

9

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!

Instrumentation answered 22/1, 2015 at 3:27 Comment(0)
S
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.

Sterilize answered 12/8, 2016 at 16:9 Comment(5)
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.Stefanistefania
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.Hildegardehildesheim
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.Instrumentation
This is no solution, you are suggesting to just delete everything and redownload.Foretaste
@Stefanistefania 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.Dayton
C
3

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/

Cacilia answered 29/12, 2022 at 2:43 Comment(1)
thanks! reset and clean did not remove the local changes in the manifests.git. A checkout of the original xml helped repo sync to overwrite the file. bad revision 'HEAD' was not a helpful error message, but your answer was!Milan
P
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
Padova answered 2/2, 2023 at 6:48 Comment(0)
H
0

I could handle a same problem using the following command:

repo forall -vc "git reset --hard"

I hope it works for you!

Hillier answered 19/10, 2023 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.