I'm trying to create a new branch of the AOSP (on my development machine) and push it to a local mirror (on a server on the same LAN). I can't find documentation of the "repo" tool that explains how to do this.
I've created a mirror of the AOSP source on my server using:
$ mkdir -p ~/aosp/mirror
$ cd ~/aosp/mirror
$ repo init -u https://android.googlesource.com/mirror/manifest --mirror
Then I sync'd on a different computer:
$ repo init -u <USERNAME>@<IP_OF_SERVER>:/home/<USERNAME>/aosp/mirror/platform/manifest.git -b android-4.2.2_1
$ repo sync
So far so good. I'm using "-b android-4.2.2_1" because I need my development to use this version of JellyBean as a baseline.
Then I create a new branch using "repo start":
$ repo start my-branch-name --all
Still good. The problem is, I can't figure out how to "push" this branch to the remote server.
When I do repo info
I see:
Manifest branch: refs/tags/android-4.2.2_r1
Manifest merge branch: android-4.2.2_r1
Manifest groups: all,-notdefault
----------------------------
Project: platform/abi/cpp
Mount path: /home/<username>/<project_name>/android/abi/cpp
Current revision: refs/tags/android-4.2.2_r1
Local Branches: 1 [my-branch-name]
---------------------------
....
When I try repo upload
I get:
no branches ready for upload
I then tried repo forall -c "git push aosp my-branch-name"
which does push the local branches to each remote repository, but it seems like this is not the proper way to do it. In particular, if I try creating a new client, and try syncing to the branch it doesn't work.
$ repo init -u <USERNAME>@<IP_OF_SERVER>:/home/<USERNAME>/aosp/mirror/platform/manifest.git -b my-branch-name
error: revision my-branch-name in manifests not found
What is the proper way to create a "Manifest branch"?
The
repo start
command creates a local branch based on the current upstream branch. Runningrepo upload
will upload any local commits on the currently checked-out branch for review to the upstream branch hosted by the Gerrit server listed in the manifest file. If the type of push you want to do doesn't match this use case you'll have to use the underlying Git commands for the pushing. You can still userepo start
though (but you don't have to).To create a manifest branch,
repo start
andrepo upload
aren't useful. Unlike other gits that Repo manages, you should make all changes to the manifest git on thedefault
branch which Repo checks out for you. Then, use plain Git commands to push your changes.The following example shows how to create a new manifest branch called
mybranch
, identical to the current upstream.Now, this by itself isn't very useful since the contents of your manifest is identical to the upstream branch – we've just cloned that branch of the manifest so while you can run
the results will be identical to what you started with:
For your mirror to be useful you also have to branch each git listed in the manifest so that you get a branch on your server where you can make changes.
Theoretically you could make changes to the same branches that you downloaded from your upstream, but that would create a mess when you attempt to sync from the upstream the next time. Don't do that.
To create branches on the server you can follow the same pattern as for the manifest:
Note the use of HEAD, the symbolic name of the currently checked out commit. Doing this for each and every git is tedious, so use the
repo forall
command:Note that the remote name is different from the manifest git (IIRC).
See
repo help forall
for a list of environment variables available for commands run byrepo forall
(REPO_PROJECT
,$REPO_LREV
, and$REPO_RREV
are probably the most useful ones).It's easy to screw up with
repo forall
, so make it a good habit to prepend your command withecho
first to have the commands that would have been run echoed to your terminal. If you're happy with the results, removeecho
to run the commands for real.By now you'll have a
mybranch
branch in all your gits, including the manifest. What remains is to change the manifest so thatwill actually check out
mybranch
in all the gits.Note that all gits don't necessarily use the default revision (which you just changed to
mybranch
). It's probably the case for the android-4.2.2_1 manifest branch, but in other cases some gits won't use the default revision but instead override it with their own revision attribute. That's perfectly fine, but it'll require you to make additional manifest changes.