Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

repo init a particular commit

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.

like image 476
renzoe Avatar asked May 30 '12 14:05

renzoe


People also ask

What is repo init command?

The 'repo init' command is run once to install and initialize repo. The latest repo source code and manifest collection is downloaded from the server and is installed in the . repo/ directory in the current working directory. When creating a new checkout, the manifest URL is the only required setting.

What is the difference between git clone and repo init?

git init vs.git clone is used to create a copy of an existing repository. Internally, git clone first calls git init to create a new repository. It then copies the data from the existing repository, and checks out a new set of working files. Learn more on the git clone page.

What does repo forall mean?

repo forall [ project-list ] -c command. Executes the given shell command in each project. The following additional environment variables are made available by repo forall : REPO_PROJECT is set to the unique name of the project. REPO_PATH is the path relative to the root of the client.

Does repo sync overwrite local changes?

repo sync does not overwrite local changes, so I don't think you're doing what you think you're doing. Can you give us a more detailed example of how you're using the command?


2 Answers

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
like image 116
Renaud Mathieu Avatar answered Sep 25 '22 06:09

Renaud Mathieu


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 is specified in the manifest file:

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

like image 24
Andrejs Cainikovs Avatar answered Sep 24 '22 06:09

Andrejs Cainikovs