Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43e430d

Browse files
committed
Repo paths are now converted to real paths, as well as all paths involved in index related work.
That way, we don't try to compare a real-path to a non-real one, which would make the implementation thinka file is not actually part of the repository.Fixesgitpython-developers#224
1 parentdfb0a9c commit43e430d

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

‎git/index/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ def _to_relative_path(self, path):
535535
if it is not within our git direcotory"""
536536
ifnotos.path.isabs(path):
537537
returnpath
538+
path=os.path.realpath(path)
538539
relative_path=path.replace(self.repo.working_tree_dir+os.sep,"")
539540
ifrelative_path==path:
540541
raiseValueError("Absolute path %r is not in git repository at %r"% (path,self.repo.working_tree_dir))

‎git/repo/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
128128
# walk up the path to find the .git dir
129129
whilecurpath:
130130
ifis_git_dir(curpath):
131-
self.git_dir=curpath
132-
self._working_tree_dir=os.path.dirname(curpath)
131+
self.git_dir=os.path.realpath(curpath)
132+
self._working_tree_dir=os.path.dirname(self.git_dir)
133133
break
134134

135135
gitpath=find_git_dir(join(curpath,'.git'))
136136
ifgitpathisnotNone:
137-
self.git_dir=gitpath
138-
self._working_tree_dir=curpath
137+
self.git_dir=os.path.realpath(gitpath)
138+
self._working_tree_dir=os.path.realpath(curpath)
139139
break
140140

141141
ifnotsearch_parent_directories:

‎git/test/lib/helper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ def wait(self):
6262

6363

6464
def_mktemp(*args):
65-
"""Wrapper around default tempfile.mktemp to fix an osx issue"""
65+
"""Wrapper around default tempfile.mktemp to fix an osx issue
66+
:note: the OSX special case was removed as it was unclear why that was needed in the first place. It seems
67+
to be just fine without it. However, if we leave this special case, and if TMPDIR is set to something custom,
68+
prefixing /private/ will lead to incorrect paths on OSX."""
6669
tdir=tempfile.mktemp(*args)
67-
ifsys.platform=='darwin':
68-
tdir='/private'+tdir
70+
# See :note: above to learn why this is comented out.
71+
# if sys.platform == 'darwin':
72+
# tdir = '/private' + tdir
6973
returntdir
7074

7175

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp