Browse Source

project: unify StartBranch flows behind git-update-ref

We're using this for git worktrees because it handles the .git file
format, but it should work for all flows.  Unify to simplify.  This
also fixes the worktree logic which duplicated .git/config settings.

Change-Id: Ie3af2e206710859dccfc376b3593f415d6830738
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256034
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Jonathan Nieder <jrn@google.com>
Mike Frysinger 6 years ago
parent
commit
746e7f664e
1 changed files with 5 additions and 13 deletions
  1. 5 13
      project.py

+ 5 - 13
project.py

@@ -1994,19 +1994,11 @@ class Project(object):
       except KeyError:
         head = None
     if revid and head and revid == head:
-      if self.use_git_worktrees:
-        self.work_git.update_ref(HEAD, revid)
-        branch.Save()
-      else:
-        ref = os.path.join(self.gitdir, R_HEADS + name)
-        try:
-          os.makedirs(os.path.dirname(ref))
-        except OSError:
-          pass
-        _lwrite(ref, '%s\n' % revid)
-        _lwrite(self.GetHeadPath(), 'ref: %s%s\n' % (R_HEADS, name))
-        branch.Save()
-        return True
+      ref = R_HEADS + name
+      self.work_git.update_ref(ref, revid)
+      self.work_git.symbolic_ref(HEAD, ref)
+      branch.Save()
+      return True
 
     if GitCommand(self,
                   ['checkout', '-b', branch.name, revid],