diff options
Diffstat (limited to 'git/repo')
| -rw-r--r-- | git/repo/base.py | 18 | ||||
| -rw-r--r-- | git/repo/fun.py | 3 |
2 files changed, 18 insertions, 3 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): diff --git a/git/repo/fun.py b/git/repo/fun.py index 1ee11ffc..2321dbc8 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -26,6 +26,7 @@ __all__ = ('rev_parse', 'is_git_dir', 'touch', 'find_git_dir', 'name_to_object', def touch(filename): fp = open(filename, "ab") fp.close() + return filename def is_git_dir(d): @@ -296,7 +297,7 @@ def rev_parse(repo, rev): raise ValueError("Invalid token: %r" % token) # END end handle tag except (IndexError, AttributeError): - raise BadObject("Invalid Revision in %s" % rev) + raise BadName("Invalid revision spec '%s' - not enough parent commits to reach '%s%i'" % (rev, token, num)) # END exception handling # END parse loop |
