diff options
-rw-r--r-- | project.py | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -986,11 +986,9 @@ class Project(object): | |||
986 | return None | 986 | return None |
987 | 987 | ||
988 | def IsRebaseInProgress(self): | 988 | def IsRebaseInProgress(self): |
989 | w = self.worktree | 989 | return (os.path.exists(self.work_git.GetDotgitPath('rebase-apply')) or |
990 | g = os.path.join(w, '.git') | 990 | os.path.exists(self.work_git.GetDotgitPath('rebase-merge')) or |
991 | return os.path.exists(os.path.join(g, 'rebase-apply')) \ | 991 | os.path.exists(os.path.join(self.worktree, '.dotest'))) |
992 | or os.path.exists(os.path.join(g, 'rebase-merge')) \ | ||
993 | or os.path.exists(os.path.join(w, '.dotest')) | ||
994 | 992 | ||
995 | def IsDirty(self, consider_untracked=True): | 993 | def IsDirty(self, consider_untracked=True): |
996 | """Is the working directory modified in some way? | 994 | """Is the working directory modified in some way? |
@@ -3232,11 +3230,28 @@ class Project(object): | |||
3232 | finally: | 3230 | finally: |
3233 | p.Wait() | 3231 | p.Wait() |
3234 | 3232 | ||
3235 | def GetHead(self): | 3233 | def GetDotgitPath(self, subpath=None): |
3234 | """Return the full path to the .git dir. | ||
3235 | |||
3236 | As a convenience, append |subpath| if provided. | ||
3237 | """ | ||
3236 | if self._bare: | 3238 | if self._bare: |
3237 | path = os.path.join(self._project.gitdir, HEAD) | 3239 | dotgit = self._gitdir |
3238 | else: | 3240 | else: |
3239 | path = self._project.GetHeadPath() | 3241 | dotgit = os.path.join(self._project.worktree, '.git') |
3242 | if os.path.isfile(dotgit): | ||
3243 | # Git worktrees use a "gitdir:" syntax to point to the scratch space. | ||
3244 | with open(dotgit) as fp: | ||
3245 | setting = fp.read() | ||
3246 | assert setting.startswith('gitdir:') | ||
3247 | gitdir = setting.split(':', 1)[1].strip() | ||
3248 | dotgit = os.path.normpath(os.path.join(self._project.worktree, gitdir)) | ||
3249 | |||
3250 | return dotgit if subpath is None else os.path.join(dotgit, subpath) | ||
3251 | |||
3252 | def GetHead(self): | ||
3253 | """Return the ref that HEAD points to.""" | ||
3254 | path = self.GetDotgitPath(subpath=HEAD) | ||
3240 | try: | 3255 | try: |
3241 | with open(path) as fd: | 3256 | with open(path) as fd: |
3242 | line = fd.readline() | 3257 | line = fd.readline() |