On Wednesday, April 03, 2013 at 04:31 EDT,
Rafeah Rahim <
rafeah....@gmail.com> wrote:
> Another newbie repo question which I hope someone can enlighten me as
> I have been goggling for the answer and I still don't seem to get it.
> :(
>
> After I sync the code from my local AOSP mirror,
> $repo init -u ssh://<aosp_mirror_server>/aosp_mirror/manifest.git -b
> <codebranch>
> $repo sync
Weird Git URL. I had expected platform/manifest or
someprefix/platform/manifest.
> I check all the git repositories and it all shows not on branch.
> $repo forall -c 'echo $REPO_PROJECT;git status'
> device/common
> # Not currently on any branch.
> nothing to commit (working directory clean)
> ....
(You may find 'repo status' useful.')
> Q1/ Why does each repo project shows "Not currently on any branch."?
> I assume it will checkout the branch based on the manifest.xml file
> revision field information but it seem it is not.
Yes it does, but it doesn't create a local branch for you. When you
check out a remote branch you'll end up with a detached head (since
you can't make commits on the remote branch anyway).
> Q2/ If I use repo start <branch_name>? Where will the new topic branch
> starts for each project?
It'll be based on the current commit pointed to by the manifest.
> What I am trying to achieve here is, I want to create a new branch
> based on the manifest file information.
> Then push this new branch to the local mirror so that other developers
> can start doing development and push their changes to that branch.
>
> It is this good way to do it?
Unless you actually want to make commits on the new branch you don't
have to create any local branches. You can just push the remote branch
(which gets resolved to a commit) to the desired branch on the server:
git push ssh://hostname/project/name origin/master:refs/heads/yourmaster
Doing this for all gits becomes:
repo forall -c 'git push ssh://hostname/$REPO_PROJECT \
origin/master:refs/heads/yourmaster'
(If you can push to the same URL as you pull you can replace the ssh://
URL with the name of the remote, probably 'aosp'. Some sites use
asymmetric URLs where clients pull from read-only slaves but push all
changes to the master server. Even if you don't need this now you might
want to consider making it an easy transition in the future by not
hardcoding in too many places, including the brains of your users, that
your pull and push URLs are identical.)
Now, you shouldn't assume that origin/master is the branch listed for
all projects in the manifest. At times in the past some projects have
used different branches by overriding the 'revision' attribute in the
manifest. If that's the case now you need to decide what to do about it.
Do you want to use the same internal development branch everywhere, or
do you want your branch name to match that of the upstream branch?
Anyway, $REPO_RREV will probably be useful here.
> Also, after I push the new branch to the AOSP mirror, how do I update
> the manifest file so that the other developer will start using my new
> branch?
cd .repo/manifests
sed -i 's/<default revision="master"/<default revision="yourmaster"/' \
default.xml
git commit -a -m 'Changed default revision from master to yourmaster'
git push ssh://hostname/platform/manifest HEAD:refs/heads/yourmaster
Or why not push to refs/for/yourmaster to have someone review your
change?
As always, I recommend keeping upstream branches in a namespace separate
from your own branches, in this case e.g. by prefixing the AOSP branches
with 'aosp/'. You could do it the other way around too and have your own
branches under e.g. 'yourcompanyname/', but since that assumes you never
have more than one upstream I favor the first option.
--
Magnus Bäck
ba...@google.com