From abc2e538c6f2fe50f93e6c3fe927236bb41f94f4 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Thu, 12 Jun 2008 03:01:09 -0700 Subject: cmd: properly handle cwd for repos with work trees This is a fix on top of Govind's latest performance improvement. self._cwd was always set to self._git_dir which means a lot of commands that require work trees were not available to GitPython. Execute now uses self._cwd which is equal to self._git_dir by default, and self.get_work_tree() if a work tree exists. Signed-off-by: David Aguilar --- lib/git/cmd.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/git/cmd.py') diff --git a/lib/git/cmd.py b/lib/git/cmd.py index 55e81e78..d3a7e36b 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -24,6 +24,9 @@ class Git(MethodMissingMixin): self._git_dir = None self._is_in_repo = not not self.get_git_dir() self._work_tree = None + self._cwd = self._git_dir + if self._git_dir: + self._cwd = self.get_work_tree() def _is_git_dir(self, d): """ This is taken from the git setup.c:is_git_directory @@ -115,7 +118,7 @@ class Git(MethodMissingMixin): # Start the process proc = subprocess.Popen(command, - cwd=self._git_dir, + cwd=self._cwd, stdin=istream, stderr=stderr, stdout=subprocess.PIPE -- cgit v1.2.1