@@ -8,7 +8,7 @@ def _git_toplevel(path):
8
8
out = subprocess .check_output ([
9
9
'git' , 'rev-parse' , '--show-toplevel' ,
10
10
], cwd = (path or '.' ), universal_newlines = True )
11
- return os .path .realpath (out .strip ())
11
+ return os .path .normcase ( os . path . realpath (out .strip () ))
12
12
except subprocess .CalledProcessError :
13
13
# git returned error, we are not in a git repo
14
14
return None
@@ -26,7 +26,7 @@ def _git_ls_files_and_dirs(toplevel):
26
26
git_files = set ()
27
27
git_dirs = set ([toplevel ])
28
28
for member in tf .getmembers ():
29
- name = member .name .replace ('/' , os .path .sep )
29
+ name = os . path . normcase ( member .name ) .replace ('/' , os .path .sep )
30
30
if member .type == tarfile .DIRTYPE :
31
31
git_dirs .add (name )
32
32
else :
@@ -44,19 +44,21 @@ def find_files(path=''):
44
44
if not toplevel :
45
45
return []
46
46
git_files , git_dirs = _git_ls_files_and_dirs (toplevel )
47
- realpath = os .path .realpath (path )
47
+ realpath = os .path .normcase ( os . path . realpath (path ) )
48
48
assert realpath .startswith (toplevel )
49
49
assert realpath in git_dirs
50
50
seen = set ()
51
51
res = []
52
52
for dirpath , dirnames , filenames in os .walk (realpath , followlinks = True ):
53
- realdirpath = os .path .realpath (dirpath ) # resolve symlink
53
+ # dirpath with symlinks resolved
54
+ realdirpath = os .path .normcase (os .path .realpath (dirpath ))
54
55
if realdirpath not in git_dirs or realdirpath in seen :
55
56
dirnames [:] = []
56
57
continue
57
58
for filename in filenames :
58
- fullfilename = os .path .join (dirpath , filename ) # with symlink
59
- if os .path .realpath (fullfilename ) in git_files :
59
+ # dirpath + filename with symlinks preserved
60
+ fullfilename = os .path .join (dirpath , filename )
61
+ if os .path .normcase (os .path .realpath (fullfilename )) in git_files :
60
62
res .append (
61
63
os .path .join (path , os .path .relpath (fullfilename , path )))
62
64
seen .add (realdirpath )
0 commit comments