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. Running repo 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 use repo start
though (but you don't have to).
To create a manifest branch, repo start
and repo upload
aren't useful. Unlike other gits that Repo manages, you should make all changes to the manifest git on the default
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.
cd .repo/manifests
git push origin default:refs/heads/mybranch
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
repo init -u ssh://git.example.com/platform/manifest -b mybranch
the results will be identical to what you started with:
repo init -u ssh://git.example.com/platform/manifest -b android-4.2.2_1
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:
cd build
git push ssh://git.example.com/platform/build HEAD:refs/heads/mybranch
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:
repo forall -c 'git push aosp HEAD:refs/heads/mybranch'
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 by repo 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 with echo
first to have the commands that would have been run echoed to your terminal. If you're happy with the results, remove echo
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 that
repo init -u ssh://git.example.com/platform/manifest -b mybranch
will actually check out mybranch
in all the gits.
cd .repo/manifests
vi default.xml
[ Change the default revision from refs/tags/android-4.2.2_1
or whatever it says to 'mybranch'. ]
git commit -a -m 'Changed default revision to mybranch.'
git push origin default:refs/heads/mybranch
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.