aboutsummaryrefslogtreecommitdiff
path: root/git/repo/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/repo/base.py')
-rw-r--r--git/repo/base.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index 6d9af6d4..ef12473b 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -131,14 +131,18 @@ class Repo(object):
# walk up the path to find the .git dir
while curpath:
+ # ABOUT os.path.NORMPATH
+ # It's important to normalize the paths, as submodules will otherwise initialize their
+ # repo instances with paths that depend on path-portions that will not exist after being
+ # removed. It's just cleaner.
if is_git_dir(curpath):
- self.git_dir = curpath
+ self.git_dir = os.path.normpath(curpath)
self._working_tree_dir = os.path.dirname(self.git_dir)
break
gitpath = find_git_dir(join(curpath, '.git'))
if gitpath is not None:
- self.git_dir = gitpath
+ self.git_dir = os.path.normpath(gitpath)
self._working_tree_dir = curpath
break
@@ -864,6 +868,16 @@ class Repo(object):
self.git.archive(treeish, *path, **kwargs)
return self
+ def has_separate_working_tree(self):
+ """
+ :return: True if our git_dir is not at the root of our working_tree_dir, but a .git file with a
+ platform agnositic symbolic link. Our git_dir will be whereever the .git file points to
+ :note: bare repositories will always return False here
+ """
+ if self.bare:
+ return False
+ return os.path.isfile(os.path.join(self.working_tree_dir, '.git'))
+
rev_parse = rev_parse
def __repr__(self):