summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/index/base.py1
-rw-r--r--git/repo/base.py8
-rw-r--r--git/test/lib/helper.py10
3 files changed, 12 insertions, 7 deletions
diff --git a/git/index/base.py b/git/index/base.py
index 66fd5b1f..c6e57f13 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -535,6 +535,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
if it is not within our git direcotory"""
if not os.path.isabs(path):
return path
+ path = os.path.realpath(path)
relative_path = path.replace(self.repo.working_tree_dir + os.sep, "")
if relative_path == path:
raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
diff --git a/git/repo/base.py b/git/repo/base.py
index d6e55553..d20d699a 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -128,14 +128,14 @@ class Repo(object):
# walk up the path to find the .git dir
while curpath:
if is_git_dir(curpath):
- self.git_dir = curpath
- self._working_tree_dir = os.path.dirname(curpath)
+ self.git_dir = os.path.realpath(curpath)
+ self._working_tree_dir = os.path.dirname(self.git_dir)
break
gitpath = find_git_dir(join(curpath, '.git'))
if gitpath is not None:
- self.git_dir = gitpath
- self._working_tree_dir = curpath
+ self.git_dir = os.path.realpath(gitpath)
+ self._working_tree_dir = os.path.realpath(curpath)
break
if not search_parent_directories:
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index 6c9f33c6..a0b8dc15 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -62,10 +62,14 @@ class StringProcessAdapter(object):
def _mktemp(*args):
- """Wrapper around default tempfile.mktemp to fix an osx issue"""
+ """Wrapper around default tempfile.mktemp to fix an osx issue
+ :note: the OSX special case was removed as it was unclear why that was needed in the first place. It seems
+ to be just fine without it. However, if we leave this special case, and if TMPDIR is set to something custom,
+ prefixing /private/ will lead to incorrect paths on OSX."""
tdir = tempfile.mktemp(*args)
- if sys.platform == 'darwin':
- tdir = '/private' + tdir
+ # See :note: above to learn why this is comented out.
+ # if sys.platform == 'darwin':
+ # tdir = '/private' + tdir
return tdir