From 746e7f664e306e823a40cd95a127516aa522ed8f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 19 Feb 2020 15:49:02 -0500 Subject: [PATCH] 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 Reviewed-by: Jonathan Nieder --- project.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/project.py b/project.py index a5d35bf3..2112ee32 100644 --- a/project.py +++ b/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],