diff options
| -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 | ||
