| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,6 +124,8 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals | |||
| 124 | 124 | repo = Repo("~/Development/git-python.git") | |
| 125 | 125 | repo = Repo("$REPOSITORIES/Development/git-python.git") | |
| 126 | 126 | ||
| 127 | + if `None, current-directory is used. | ||
| 128 | + The :envvar:`GIT_DIR` if set and not empty takes precendance over this parameter. | ||
| 127 | 129 | :param odbt: | |
| 128 | 130 | Object DataBase type - a type which is constructed by providing | |
| 129 | 131 | the directory containing the database objects, i.e. .git/objects. It will | |
@@ -136,17 +138,19 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals | |||
| 136 | 138 | :raise InvalidGitRepositoryError: | |
| 137 | 139 | :raise NoSuchPathError: | |
| 138 | 140 | :return: git.Repo """ | |
| 139 | - epath = _expand_path(path or os.getcwd()) | ||
| 140 | 141 | self.git = None # should be set for __del__ not to fail in case we raise | |
| 142 | + epath = os.getenv('GIT_DIR') | ||
| 143 | + epath = _expand_path(epath or path or os.getcwd()) | ||
| 141 | 144 | if not os.path.exists(epath): | |
| 142 | 145 | raise NoSuchPathError(epath) | |
| 143 | 146 | ||
| 144 | 147 | self.working_dir = None | |
| 145 | 148 | self._working_tree_dir = None | |
| 146 | 149 | self.git_dir = None | |
| 147 | - curpath = os.getenv('GIT_DIR', epath) | ||
| 148 | 150 | ||
| 149 | - # walk up the path to find the .git dir | ||
| 151 | + ## Walk up the path to find the `.git` dir. | ||
| 152 | + # | ||
| 153 | + curpath = epath | ||
| 150 | 154 | while curpath: | |
| 151 | 155 | # ABOUT os.path.NORMPATH | |
| 152 | 156 | # It's important to normalize the paths, as submodules will otherwise initialize their | |
| Back | FazBrowse Home | New Git URL |
0 commit comments