create remote upstream branch if not existed

with optimized fetch, remote branch might not be created if no need to fetch.
all kinds of issues are created because of the wrong presumption that remote
branch always exists.
so, just create remote upstream branch if not existed once and for all.

Change-Id: I191ecdb83613e55eb1ef7f0e66d9e0ba57fb234d
diff --git a/project.py b/project.py
index e90d028..3029e58 100644
--- a/project.py
+++ b/project.py
@@ -1198,7 +1198,7 @@
     ref = os.path.join(self.gitdir, branch)
     if os.path.exists(ref): return
     try:
-      self.work_git.rev_parse(branch)
+      self.bare_git.rev_parse(branch)
     except GitError:
       try:
         os.makedirs(os.path.dirname(ref))
@@ -1309,7 +1309,6 @@
                               current_branch_only=current_branch_only,
                               no_tags=no_tags, prune=prune)):
       return False
-
     if self.worktree:
       self._InitMRef()
     else:
@@ -1318,6 +1317,9 @@
         os.remove(os.path.join(self.gitdir, 'FETCH_HEAD'))
       except OSError:
         pass
+    if not self.manifest.IsMirror:
+      '''make sure remote branch is created'''
+      self._CreateRemoteUpstreamBranch()
     return True
 
   def PostRepoUpgrade(self):
@@ -1924,6 +1926,10 @@
       result.extend(subproject.GetDerivedSubprojects())
     return result
 
+  def _CreateRemoteUpstreamBranch(self):
+    if self.upstream and not ID_RE.match(self.upstream):
+      branch = self.GetRemote(self.remote.name).ToLocal(self.upstream)
+      self._CreateLocalMergeBranch(branch, self.revisionExpr)
 
 # Direct Git Commands ##
   def _CheckForSha1(self):