diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2017-09-28 14:25:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-28 14:25:38 +0200 |
commit | 3eb497ba1bbcaeb05a413a226fd78e54a29a3ff5 (patch) | |
tree | 40d875ae3ce8a0a38832647a5af34f1e9564c417 /git/repo/base.py | |
parent | 2dca537f505e93248739478f17f836ae79e00783 (diff) | |
parent | a2d678792d3154d5de04a5225079f2e0457b45b7 (diff) | |
download | gitpython-3eb497ba1bbcaeb05a413a226fd78e54a29a3ff5.tar.gz |
Merge pull request #664 from Horgix/path_expansion
util: move expand_path from repo/base and use it in Git class init
Diffstat (limited to 'git/repo/base.py')
-rw-r--r-- | git/repo/base.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index 28bb2a5d..74d56ee5 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -29,7 +29,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 @@ -50,10 +50,6 @@ BlameEntry = namedtuple('BlameEntry', ['commit', 'linenos', 'orig_path', 'orig_l __all__ = ('Repo',) -def _expand_path(p): - return osp.normpath(osp.abspath(osp.expandvars(osp.expanduser(p)))) - - class Repo(object): """Represents a git repository and allows you to query references, gather commit information, generate diffs, create and clone repositories query @@ -121,7 +117,7 @@ class Repo(object): epath = os.getcwd() if Git.is_cygwin(): epath = decygpath(epath) - epath = _expand_path(epath or path or os.getcwd()) + epath = expand_path(epath or path or os.getcwd()) if not os.path.exists(epath): raise NoSuchPathError(epath) @@ -148,7 +144,7 @@ class Repo(object): sm_gitpath = find_worktree_git_dir(dotgit) if sm_gitpath is not None: - self.git_dir = _expand_path(sm_gitpath) + self.git_dir = expand_path(sm_gitpath) self._working_tree_dir = curpath break @@ -867,7 +863,7 @@ class Repo(object): :return: ``git.Repo`` (the newly created repo)""" if path: - path = _expand_path(path) + path = expand_path(path) if mkdir and path and not osp.exists(path): os.makedirs(path, 0o755) |