diff options
author | Mike Frysinger <vapier@google.com> | 2020-02-23 23:24:40 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2020-02-24 17:41:40 +0000 |
commit | 9f91c4395acf03b89738225b329c19fecaf46a3e (patch) | |
tree | ef21b3f41e55968d657b6152870b6ffb5ef35cd6 /project.py | |
parent | 4b0eb5a4418babdb12ae6fc50150473dc6dd5733 (diff) | |
download | git-repo-9f91c4395acf03b89738225b329c19fecaf46a3e.tar.gz |
project: replace GetHeadPath with new git helperv2.4
Change-Id: I79931cb484508c78f6a8b8413d05b85ed8bc6d98
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256533
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 17 |
1 files changed, 3 insertions, 14 deletions
@@ -1952,18 +1952,6 @@ class Project(object): | |||
1952 | return True | 1952 | return True |
1953 | 1953 | ||
1954 | # Branch Management ## | 1954 | # Branch Management ## |
1955 | def GetHeadPath(self): | ||
1956 | """Return the full path to the HEAD ref.""" | ||
1957 | dotgit = os.path.join(self.worktree, '.git') | ||
1958 | if os.path.isfile(dotgit): | ||
1959 | # Git worktrees use a "gitdir:" syntax to point to the scratch space. | ||
1960 | with open(dotgit) as fp: | ||
1961 | setting = fp.read() | ||
1962 | assert setting.startswith('gitdir:') | ||
1963 | gitdir = setting.split(':', 1)[1].strip() | ||
1964 | dotgit = os.path.join(self.worktree, gitdir) | ||
1965 | return os.path.join(dotgit, HEAD) | ||
1966 | |||
1967 | def StartBranch(self, name, branch_merge='', revision=None): | 1955 | def StartBranch(self, name, branch_merge='', revision=None): |
1968 | """Create a new branch off the manifest's revision. | 1956 | """Create a new branch off the manifest's revision. |
1969 | """ | 1957 | """ |
@@ -2046,7 +2034,8 @@ class Project(object): | |||
2046 | # Same revision; just update HEAD to point to the new | 2034 | # Same revision; just update HEAD to point to the new |
2047 | # target branch, but otherwise take no other action. | 2035 | # target branch, but otherwise take no other action. |
2048 | # | 2036 | # |
2049 | _lwrite(self.GetHeadPath(), 'ref: %s%s\n' % (R_HEADS, name)) | 2037 | _lwrite(self.work_git.GetDotgitPath(subpath=HEAD), |
2038 | 'ref: %s%s\n' % (R_HEADS, name)) | ||
2050 | return True | 2039 | return True |
2051 | 2040 | ||
2052 | return GitCommand(self, | 2041 | return GitCommand(self, |
@@ -2079,7 +2068,7 @@ class Project(object): | |||
2079 | 2068 | ||
2080 | revid = self.GetRevisionId(all_refs) | 2069 | revid = self.GetRevisionId(all_refs) |
2081 | if head == revid: | 2070 | if head == revid: |
2082 | _lwrite(self.GetHeadPath(), '%s\n' % revid) | 2071 | _lwrite(self.work_git.GetDotgitPath(subpath=HEAD), '%s\n' % revid) |
2083 | else: | 2072 | else: |
2084 | self._Checkout(revid, quiet=True) | 2073 | self._Checkout(revid, quiet=True) |
2085 | 2074 | ||