aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/git.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/git.py')
-rw-r--r--libbe/git.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/libbe/git.py b/libbe/git.py
index 398585f..172c324 100644
--- a/libbe/git.py
+++ b/libbe/git.py
@@ -22,7 +22,11 @@ def strip_git(filename):
# Find the base path of the GIT tree, in order to strip that leading
# path from arguments to git -- it doesn't like absolute paths.
if os.path.isabs(filename):
- filename = filename[len(git_repo_for_path('.'))+1:]
+ absRepoDir = os.path.abspath(git_repo_for_path('.'))
+ absRepoSlashedDir = os.path.join(absRepoDir,"")
+ assert filename.startswith(absRepoSlashedDir), \
+ "file %s not in git repo %s" % (filename, absRepoSlashedDir)
+ filename = filename.lstrip(absRepoSlashedDir)
return filename
def invoke_client(*args, **kwargs):
@@ -102,7 +106,10 @@ def git_repo_for_path(path):
"""Find the root of the deepest repository containing path."""
# Assume that nothing funny is going on; in particular, that we aren't
# dealing with a bare repo.
- return os.path.dirname(git_dir_for_path(path))
+ dirname = os.path.dirname(git_dir_for_path(path))
+ if dirname == '' : # os.path.dirname('filename') == ''
+ dirname = '.'
+ return dirname
def git_dir_for_path(path):
"""Find the git-dir of the deepest repo containing path."""