diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-19 15:49:02 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-02-21 05:12:47 +0000 |
commit | 746e7f664e306e823a40cd95a127516aa522ed8f (patch) | |
tree | d8d697039729fdb05c69566001f221bd23230a30 /project.py | |
parent | f241f8c094364722c33dd879ff6a0dc132a24bc2 (diff) | |
download | git-repo-746e7f664e306e823a40cd95a127516aa522ed8f.tar.gz |
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>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -1994,19 +1994,11 @@ class Project(object): | |||
1994 | except KeyError: | 1994 | except KeyError: |
1995 | head = None | 1995 | head = None |
1996 | if revid and head and revid == head: | 1996 | if revid and head and revid == head: |
1997 | if self.use_git_worktrees: | 1997 | ref = R_HEADS + name |
1998 | self.work_git.update_ref(HEAD, revid) | 1998 | self.work_git.update_ref(ref, revid) |
1999 | branch.Save() | 1999 | self.work_git.symbolic_ref(HEAD, ref) |
2000 | else: | 2000 | branch.Save() |
2001 | ref = os.path.join(self.gitdir, R_HEADS + name) | 2001 | return True |
2002 | try: | ||
2003 | os.makedirs(os.path.dirname(ref)) | ||
2004 | except OSError: | ||
2005 | pass | ||
2006 | _lwrite(ref, '%s\n' % revid) | ||
2007 | _lwrite(self.GetHeadPath(), 'ref: %s%s\n' % (R_HEADS, name)) | ||
2008 | branch.Save() | ||
2009 | return True | ||
2010 | 2002 | ||
2011 | if GitCommand(self, | 2003 | if GitCommand(self, |
2012 | ['checkout', '-b', branch.name, revid], | 2004 | ['checkout', '-b', branch.name, revid], |