repo init a particular commit

丶灬走出姿态 提交于 2019-12-01 03:21:49

问题


Im building the Cyanogenmod 9 (Android ICS) system for a Nexus S phone (samsung crespo). 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).

How do I repo init to a particular commit? In my case I want the last commit using the google android-4.0.3_r1 branch. Is this one:

  • https://github.com/CyanogenMod/android/commit/5f5da775f570f2995c8ff2db98e6c8b40852911c

If I do

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.

Thanks in Advance.


回答1:


Long answer:

You can't specify a branch name (or SHA, or whatever else) to repo, it will not work. Here's why:

repo is a script that handles a collection of repository projects (which in fact are independent git's). 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. -b is relevant only for repo git during repo init.

Here is an example of .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.
I.e., manifest, that will contain SHA's (or tags, which are practically the same, if they are present) instead of branch names. This way every git project within your repository will point into some commit, that was the latest greatest when the build was executed:

<?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.

Short answer:

You need to obtain manifest_static.xml of the particular build.

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. More info on local_manifest.xml usage is here.




回答2:


I figured it out. If your have a tag in a manifest file (version.xml for example). You can repo init to a specific tag with the following command:

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



回答3:


I don't have sufficient authority to submit a comment, but I just wanted to clarify Andrejs Cainikovs's answer.

Repo does accept a commit-id SHA in addition to a branch ref as an argument to the -b option.

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.



来源:https://stackoverflow.com/questions/10818758/repo-init-a-particular-commit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!