简体   繁体   English

AOSP 回购同步错误,坏 object HEAD

[英]AOSP repo sync error, bad object HEAD

I have worked with and successfully compiled and installed AOSP about a year or two ago.大约一两年前,我已经使用并成功编译和安装了 AOSP。 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.我试过删除 WORKING_DIRECTORY 中的 .repo 文件夹并在那里重新初始化 repo。 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!任何帮助寻找解决方案的帮助将不胜感激!

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)解决方案是清除错误消息中指定的关联项目的 .git 文件夹(在本例中为 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.这也在多个项目中报告,所以我反复应用它,直到整个同步成功。

In my case, "manifests" was a problem.就我而言,“清单”是个问题。

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

And I resolved by removing this folder.我通过删除这个文件夹来解决。

rm -rf.repo/manifests/.git/ rm -rf.repo/清单/.git/

The answer by @dr_g worked for me. @dr_g回答对我有用。

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.作为该解决方案的补充,我使用以下脚本片段来清理一个 go 中的一堆失败的 GIT 存储库。根据您的要求编辑数组arr中的条目。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM