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