2929from git .objects import Submodule , RootModule , Commit
3030from git .refs import HEAD , Head , Reference , TagReference
3131from git .remote import Remote , add_progress , to_progress_instance
32- from git .util import Actor , finalize_process , decygpath , hex_to_bin
32+ from git .util import Actor , finalize_process , decygpath , hex_to_bin , expand_path
3333import os .path as osp
3434
3535from .fun import rev_parse , is_git_dir , find_submodule_git_dir , touch , find_worktree_git_dir
5050__all__ = ('Repo' ,)
5151
5252
53- def _expand_path (p ):
54- return osp .normpath (osp .abspath (osp .expandvars (osp .expanduser (p ))))
55-
56-
5753class Repo (object ):
5854 """Represents a git repository and allows you to query references,
5955 gather commit information, generate diffs, create and clone repositories query
@@ -121,7 +117,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
121117 epath = os .getcwd ()
122118 if Git .is_cygwin ():
123119 epath = decygpath (epath )
124- epath = _expand_path (epath or path or os .getcwd ())
120+ epath = expand_path (epath or path or os .getcwd ())
125121 if not os .path .exists (epath ):
126122 raise NoSuchPathError (epath )
127123
@@ -148,7 +144,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
148144 sm_gitpath = find_worktree_git_dir (dotgit )
149145
150146 if sm_gitpath is not None :
151- self .git_dir = _expand_path (sm_gitpath )
147+ self .git_dir = expand_path (sm_gitpath )
152148 self ._working_tree_dir = curpath
153149 break
154150
@@ -867,7 +863,7 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs):
867863
868864 :return: ``git.Repo`` (the newly created repo)"""
869865 if path :
870- path = _expand_path (path )
866+ path = expand_path (path )
871867 if mkdir and path and not osp .exists (path ):
872868 os .makedirs (path , 0o755 )
873869
0 commit comments