diff options
Diffstat (limited to 'git/repo/base.py')
-rw-r--r-- | git/repo/base.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index d575466d..58e533aa 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -30,7 +30,7 @@ from git.index import IndexFile from git.objects import Submodule, RootModule, Commit from git.refs import HEAD, Head, Reference, TagReference from git.remote import Remote, add_progress, to_progress_instance -from git.util import Actor, finalize_process, decygpath, hex_to_bin +from git.util import Actor, finalize_process, decygpath, hex_to_bin, expand_path import os.path as osp from .fun import rev_parse, is_git_dir, find_submodule_git_dir, touch, find_worktree_git_dir @@ -51,13 +51,6 @@ BlameEntry = namedtuple('BlameEntry', ['commit', 'linenos', 'orig_path', 'orig_l __all__ = ('Repo',) -def _expand_path(p, expand_vars=True): - p = osp.expanduser(p) - if expand_vars: - p = osp.expandvars(p) - return osp.normpath(osp.abspath(p)) - - class Repo(object): """Represents a git repository and allows you to query references, gather commit information, generate diffs, create and clone repositories query @@ -126,11 +119,12 @@ class Repo(object): epath = os.getcwd() if Git.is_cygwin(): epath = decygpath(epath) + epath = epath or path or os.getcwd() if expand_vars and ("%" in epath or "$" in epath): warnings.warn("The use of environment variables in paths is deprecated" + "\nfor security reasons and may be removed in the future!!") - epath = _expand_path(epath, expand_vars) + epath = expand_path(epath, expand_vars) if not os.path.exists(epath): raise NoSuchPathError(epath) @@ -157,7 +151,7 @@ class Repo(object): sm_gitpath = find_worktree_git_dir(dotgit) if sm_gitpath is not None: - self.git_dir = _expand_path(sm_gitpath, expand_vars) + self.git_dir = expand_path(sm_gitpath, expand_vars) self._working_tree_dir = curpath break @@ -881,7 +875,7 @@ class Repo(object): :return: ``git.Repo`` (the newly created repo)""" if path: - path = _expand_path(path, expand_vars) + path = expand_path(path, expand_vars) if mkdir and path and not osp.exists(path): os.makedirs(path, 0o755) |