Is "repo sync" equivalent to "git remote update && git rebase origin/branch"?

Viewed 1345

In the repo sync documentation it is stated that:

If the project has been synchronized before, then repo sync is equivalent to:

git remote update
git rebase origin/branch

where branch is the currently checked-out branch in the local project directory. If the local branch isn't tracking a branch in the remote repository, then no synchronization occurs for the project.

This means that after I successfully repo init && repo sync once, then I can use

$ repo forall -c git update
$ repo forall -c git checkout -b $REPO_RREV $REPO_REMOTE/$REPO_RREV
$ repo forall -c git pull $REPO_REMOTE $REPO_RREV

in order to achieve the same outcome as repo sync.

I'm concerned about the following:

  • If repo is a tool that manages multiple git repositories with the help of a manifest.xml file, what happens if the manifest changes in the remote repository(upstream)?
  • If e.g. a new repository is added to the manifest.xml file, how is repo sync equivalent to git remote update && git rebase origin/branch?
  • Isn't repo sync also updating the manifest.xml file and then pulling the newly added repository? Because if this is the case, then repo sync is clearly not equivalent to repo forall -c git remote update && repo forall -c git rebase origin/branch.

Is repo sync equivalent to git remote update && git rebase origin/branch or the documentation is missing something? Can someone please clarify how repo sync really works under the hood from this point of view?

1 Answers

This answer is based on what I understood from the doc link you mention in your question :

  • repo sync is not executed on the sub projects, so will not be impacted by changes to their manifest.xml if they have one ;

  • the doc has several "If"s ; the one before your quote states :

  • If the project has never been synchronized, then repo sync is equivalent to git clone. All branches in the remote repository are copied to the local project directory.
  • repo sync updates the projects listed in this manifest, not the root project itself, so your root manifest.xml file is not modified by this command.

If you want to emulate repo sync with a repo forall ..., you would indeed need to take into account the actions for a new repo : git clone, and possibly some other commands.

Check the output of repo --trace sync as @ElpieKay suggested.

Related