[XDA-University] thewisenerd:
Another much deserved bump!

But, just in case, let's put this post to good use :)

I recently found myself syncing sources, after a long time, and good to have known the flags, which I should have, a long time ago :p

Let's add another to the list.

--mirror

This is one flag that's of most use to me, perhaps. As I build a lot of ROMs (used to, at least) (*not* cm), I found myself syncing CM's sources first, deleting all folders instead of the .repo folder, and referencing from the folder. Instead of having to do that everytime, and that I don't use the CM sources anyways, I found this flag in the man pages. Here's what `repo help init` reads:

--mirror create a replica of the remote repositories rather
than a client working directory

So, when I synced CM sources freshly, I used this flag first. Thus, a working directory isn't created, hence saving my disk space, and me having to delete all folders (-x .repo) every time I hit repo sync :angel:

Another "issue" that I faced was creating a local_manifests folder, with local manifest stating to remove all the darwin repos, which I don't need anyways, as I don't have a darwin PC. Was fed up with doing this (finding all repos containing "darwin", copy-pasting them, remove-project'ing them, and all), so I decided to create a oneliner for that, hopefully solving my problem, in a few seconds (should it work correctly)

The following code should create a local_manifests.xml file in your working directory, which you can copy to .repo/local_manifests/

echo -e $( cat .repo/manifests/default.xml | grep -i "?xml v" ) $( cat .repo/manifests/default.xml | grep -i "<manifest" ) $( cat .repo/manifests/default.xml | grep -i "darwin" | sed s@"<project "@"<remove-project "@g | awk '{for (i=1;i<=NF;i++) {if ( ($i ~ /remove-project/) || ($i ~ /name=/) || ($i ~ /\/>/)) {print $i;}}}' ) $( cat .repo/manifests/default.xml | grep -i "</manifest" ) | sed s@"> <"@">\n<"@g | tee local_manifests.xml

Note that this can be automated too, by prefixing `mkdir -p .repo/local_manifests/` and postfixing `mv local_manifests.xml repo/local_manifests/local_manifest.xml` to the above command, but I'm not doing that... One shouldn't get too lazy :p

In case you want the <remove-project lines to have a two char spaces, before starting, pipe out the text through "sed s@"<remove"@" <remove"@g", before piping it to tee, like this:

echo -e $( cat .repo/manifests/default.xml | grep -i "?xml v" ) $( cat .repo/manifests/default.xml | grep -i "<manifest" ) $( cat .repo/manifests/default.xml | grep -i "darwin" | sed s@"<project "@"<remove-project "@g | awk '{for (i=1;i<=NF;i++) {if ( ($i ~ /remove-project/) || ($i ~ /name=/) || ($i ~ /\/>/)) {print $i;}}}' ) $( cat .repo/manifests/default.xml | grep -i "</manifest" ) | sed s@"> <"@">\n<"@g | sed s@"<remove"@" <remove"@g | tee local_manifests.xml

I'd really like to explain how this oneliner actually works, but its around midnight, and I'm feeling sleepy... zzz...

Anyways, one last thing I wanted to share, was fixing errors with repo sync, when you're syncing sources while referencing to another repo. I often do this, and get errors with certain projects, which do not have a very similar commit history, and I often get errors like "fatal: revision walk-up failed" or similar.

One fix that I would suggest for that, is that you find the project which's causing the errors (let's call it xyz), and go to .repo/project-objects (with newer repo binaries), or .repo/projects (with older repo binaries). I'll go with project-objects.

There, you'll find folders, which are named after the <remote>'s defined in your default.xml (and local_manifests). Check with default.xml, and see which remote is used for syncing xyz. Next, browse into the folder, and find the folder xyz.git/objects/info/. There, you'll find a file named "alternates". Delete that file, and the next time repo syncs, it will not try to "walk-up" commit history from the project you referenced it to, hence fixing your sync errors :)

The `alternates` file can be very useful too :)

For example, if you think a project is being resynced, from scratch, you can go to .repo/project-objects/project_name.git/objects/info/, and check if the alternates file exists. If not, you can create one, pointing to a vaild repo --mirror.

an example (for referencing a --mirror repo):

/home/user/works/cyanogenmod/CyanogenMod/android_frameworks_base.git/objects

another example (for referencing a working directory repo)

/home/user/works/cm11/.repo/project-objects/CyanogenMod/android_frameworks_base.git/objects

This should hopefully save you a couple more GBs of download, in case repo doesn't create correct references (rare, but happens).

Edit: just a couple of pages ago, someone had talked about groups. That should help you too. But I haven't experimented with them, yet ;)