简体   繁体   English

回购初始化一个特定的提交

[英]repo init a particular commit

Im building the Cyanogenmod 9 (Android ICS) system for a Nexus S phone (samsung crespo).我正在为 Nexus S 手机 (samsung crespo) 构建 Cyanogenmod 9 (Android ICS) 系统。 The problem is that if I do:问题是如果我这样做:

repo init -u git://github.com/CyanogenMod/android.git -b ics  

The repo inits to the latest commit of ICS, in which the manifest does not include some device/samsung/ projects I need (specifically https://github.com/CyanogenMod/android_device_samsung_crespo ).回购初始化到 ICS 的最新提交,其中清单不包括我需要的一些设备/三星/项目(特别是https://github.com/CyanogenMod/android_device_samsung_crespo )。

How do I repo init to a particular commit?我如何将 init 回购到特定的提交? In my case I want the last commit using the google android-4.0.3_r1 branch.在我的例子中,我希望最后一次提交使用 google android-4.0.3_r1 分支。 Is this one:这是一个:

If I do如果我做

repo init -u git://github.com/CyanogenMod/android.git -b commit-hash repo init -u git://github.com/CyanogenMod/android.git -b commit-hash

Does not work, seems that repo init -b only support the HEAD of a branch.不起作用,似乎 repo init -b 只支持分支的 HEAD。

Thanks in Advance.提前致谢。

I figured it out.我想到了。 If your have a tag in a manifest file (version.xml for example).如果您在清单文件(例如 version.xml)中有一个标签。 You can repo init to a specific tag with the following command:您可以使用以下命令将 init 重新存储到特定标签:

repo init -u <addres> -b refs/tags/<tagname> -m version.xml

Long answer:长答案:

You can't specify a branch name (or SHA, or whatever else) to repo , it will not work.您不能为repo指定分支名称(或 SHA 或其他任何名称),它不起作用。 Here's why:原因如下:

repo is a script that handles a collection of repository projects (which in fact are independent git's). repo是一个处理存储库项目集合(实际上是独立的 git 项目)的脚本。 Project list is located in .repo git, and contains a manifest file, which basically is a list of all repository git's and they branches.项目列表位于.repo git 中,并包含一个清单文件,该文件基本上是所有存储库 git 及其分支的列表。 -b is relevant only for repo git during repo init . -b只适用于相关的repo过程中的git repo init

Here is an example of .repo/manifests/default.xml :这是.repo/manifests/default.xml的示例:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote fetch="git://address.com/" name="origin"
          review="review.address.com"/>
  <default remote="origin" revision="ics-something" sync-j="4"/>
  <manifest-server url="http://manifests.address.com:8000"/>
  <!-- sniff -->
  <project name="platform/external/libxml2" path="external/libxml2"
           revision="ics-common"/>
  <project name="platform/external/zlib" path="external/zlib"
           revision="ics-common"/>
  <project name="platform/frameworks/base" path="frameworks/base"
           revision="ics-something"/>
  <project name="platform/packages/apps/Bluetooth" path="packages/apps/Bluetooth"
           revision="ics-common"/>
  <!-- sniff -->
</manifest>

So, the correct way of obtaining the sources of the repository for the particular build is to obtain it's manifest.因此,获取特定构建的存储库源的正确方法是获取它的清单。
Ie, manifest, that will contain SHA's (or tags, which are practically the same, if they are present) instead of branch names.即清单,将包含 SHA(或标签,如果它们存在的话,实际上是相同的)而不是分支名称。 This way every git project within your repository will point into some commit, that is specified in the manifest file:这样,您存储库中的每个 git 项目都将指向清单文件中指定的某些提交:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote fetch="git://address.com/" name="origin"
          review="review.address.com"/>
  <default remote="origin" revision="ics-something" sync-j="4"/>
  <manifest-server url="http://manifests.address.com:8000"/>
  <!-- sniff -->
  <project name="platform/external/libxml2" path="external/libxml2"
           revision="refs/tags/android-4.0.4_r1.1"/>
  <project name="platform/external/zlib" path="external/zlib"
           revision="refs/tags/android-4.0.4_r1.1"/>
  <project name="platform/frameworks/base" path="frameworks/base"
           revision="ecb41a77411358d385e3fde5b4e98a5f3d9cfdd5"/>
  <project name="platform/packages/apps/Bluetooth" path="packages/apps/Bluetooth"
           revision="621bae79f1a250e443eb83d1f473c533bea493dc"/>
  <!-- sniff -->
</manifest>

As you see, the only difference between these two manifests is the revision values of repository git's.如您所见,这两个清单之间的唯一区别是存储库 git 的修订值。

Short answer:简短的回答:

You need to obtain manifest_static.xml of the particular build.您需要获取特定构建的manifest_static.xml

Or, if you just missing some project git's, then you could create local_manifest.xml file in .repo git, add missing git's there, and then repo sync from the root of your repository.或者,如果您只是缺少一些项目 git,那么您可以在.repo git 中创建local_manifest.xml文件,在那里添加缺少的 git,然后从存储库的根目录进行repo sync More info on local_manifest.xml usage is here .有关local_manifest.xml用法的更多信息在这里

I don't have sufficient authority to submit a comment, but I just wanted to clarify Andrejs Cainikovs's answer.我没有足够的权限提交评论,但我只是想澄清 Andrejs Cainikovs 的回答。

Repo does accept a commit-id SHA in addition to a branch ref as an argument to the -b option.除了作为 -b 选项的参数的分支 ref 之外,Repo还接受 commit-id SHA

As the answers suggest, this argument specifies the revision of the manifest that should be used by repo, not a revision in any of the projects that the manifest refers to.正如答案所暗示的那样,此参数指定了应由 repo 使用的清单的修订版,而不是清单所引用的任何项目中的修订版。

  • Dump the state of your reference repo to a manifest file将参考回购的 state 转储到清单文件
  • copy the file to a copy repo's .repo/manifests/将文件复制到副本仓库的.repo/manifests/
  • do the sync in the copy repo using that static manifest.使用该 static 清单在副本回购中进行同步。
[reference_repo]$ repo manifest -r -o static_manifest.xml
[copy_repo]$ rsync -a /path/to/reference_repo/static_manifest.xml /copy_repo/.repo/manifests/
[copy_repo]$ repo sync -m static_manifest.xml

Make sure in the copy-repo the static manifest is copied to the .repo/manifests/ directory and referred to by just file name in repo sync .确保在 copy-repo 中将 static 清单复制到.repo/manifests/目录,并在repo sync中仅通过文件名引用。

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

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