From 81211030c96f7530808aae0019de05a56d34e922 Mon Sep 17 00:00:00 2001 From: Steven Walter Date: Thu, 5 Feb 2009 09:51:17 -0500 Subject: [PATCH] workdir: fix locking In some cases the lockfile contained a relative path, which caused the existance test te behave oddly --- plugins/workdir.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/workdir.py b/plugins/workdir.py index 96a2c92..9b4b3d6 100644 --- a/plugins/workdir.py +++ b/plugins/workdir.py @@ -57,6 +57,13 @@ class WorkdirPlugin(YapCore): finally: os.unlink(tmplock) + def _get_repodir(self): + repo = get_output('git rev-parse --git-dir')[0] + if not repo.startswith('/'): + repo = os.path.join(os.getcwd(), repo) + repodir = os.path.dirname(repo) + return repodir + def cmd_workdir(self, branch, workdir=None): " [workdir]" @@ -67,10 +74,8 @@ class WorkdirPlugin(YapCore): raise YapError("Not a branch: %s" % branch) current = get_output("git symbolic-ref HEAD")[0] - - repo = get_output('git rev-parse --git-dir')[0] - repo = os.path.join(os.getcwd(), repo) - repodir = os.path.dirname(repo) + repodir = self._get_repodir() + repo = os.path.join(repodir, '.git') if workdir is None: repoparent, reponame = os.path.split(repodir) workdir = os.path.join(repoparent, "%s-%s" % (reponame, branch)) @@ -110,8 +115,8 @@ class WorkdirPlugin(YapCore): current = get_output("git symbolic-ref HEAD")[0] - repo = get_output('git rev-parse --git-dir')[0] - self._lock_branch(branch, repo) + repodir = self._get_repodir() + self._lock_branch(branch, repodir) try: super(WorkdirPlugin, self).cmd_switch(branch, *args, **flags) -- 2.11.4.GIT