git-update: Don't try to pull --rebase repos that are not on master
authorNirbheek Chauhan <nirbheek@centricular.com>
Tue, 2 Oct 2018 04:21:11 +0000 (09:51 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Tue, 2 Oct 2018 04:21:11 +0000 (09:51 +0530)
This fixes updating of repos that are at a specific commit and
a detached HEAD, such as openh264.

git-update

index a3875d2..7285dfb 100755 (executable)
@@ -35,6 +35,13 @@ def update_subprojects(manifest, no_interaction=False):
         if not os.path.exists(os.path.join(repo_dir, '.git')):
             continue
         revision = repos_commits.get(repo_name)
+        if not revision:
+            # If we're on a detached head because the revision= value in the
+            # wrap file is a commit, don't try to git pull --rebase because
+            # that will always fail.
+            ret = git('-C', repo_dir, 'rev-parse', '--symbolic-full-name', 'HEAD')
+            if ret.strip() == 'HEAD':
+                revision = git('rev-parse', 'HEAD').strip()
         if not update_repo(repo_name, repo_dir, revision, no_interaction):
             return False