29
29
from git .objects import Submodule , RootModule , Commit
30
30
from git .refs import HEAD , Head , Reference , TagReference
31
31
from 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
33
33
import os .path as osp
34
34
35
35
from .fun import rev_parse , is_git_dir , find_submodule_git_dir , touch , find_worktree_git_dir
50
50
__all__ = ('Repo' ,)
51
51
52
52
53
- def _expand_path (p ):
54
- return osp .normpath (osp .abspath (osp .expandvars (osp .expanduser (p ))))
55
-
56
-
57
53
class Repo (object ):
58
54
"""Represents a git repository and allows you to query references,
59
55
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
121
117
epath = os .getcwd ()
122
118
if Git .is_cygwin ():
123
119
epath = decygpath (epath )
124
- epath = _expand_path (epath or path or os .getcwd ())
120
+ epath = expand_path (epath or path or os .getcwd ())
125
121
if not os .path .exists (epath ):
126
122
raise NoSuchPathError (epath )
127
123
@@ -148,7 +144,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
148
144
sm_gitpath = find_worktree_git_dir (dotgit )
149
145
150
146
if sm_gitpath is not None :
151
- self .git_dir = _expand_path (sm_gitpath )
147
+ self .git_dir = expand_path (sm_gitpath )
152
148
self ._working_tree_dir = curpath
153
149
break
154
150
@@ -867,7 +863,7 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs):
867
863
868
864
:return: ``git.Repo`` (the newly created repo)"""
869
865
if path :
870
- path = _expand_path (path )
866
+ path = expand_path (path )
871
867
if mkdir and path and not osp .exists (path ):
872
868
os .makedirs (path , 0o755 )
873
869
0 commit comments