summaryrefslogtreecommitdiff
path: root/git/repo/fun.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/repo/fun.py')
-rw-r--r--git/repo/fun.py41
1 files changed, 21 insertions, 20 deletions
diff --git a/git/repo/fun.py b/git/repo/fun.py
index 4d852cfe..c5a8a52b 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -2,22 +2,18 @@
import os
from string import digits
+from git.compat import xrange
+from git.exc import WorkTreeRepositoryUnsupported
+from git.objects import Object
+from git.refs import SymbolicReference
+from git.util import hex_to_bin, bin_to_hex, decygpath
from gitdb.exc import (
BadObject,
BadName,
)
-from git.refs import SymbolicReference
-from git.objects import Object
-from gitdb.util import (
- join,
- isdir,
- isfile,
- dirname,
- hex_to_bin,
- bin_to_hex
-)
-from git.exc import WorkTreeRepositoryUnsupported
-from git.compat import xrange
+
+import os.path as osp
+from git.cmd import Git
__all__ = ('rev_parse', 'is_git_dir', 'touch', 'find_git_dir', 'name_to_object', 'short_to_long', 'deref_tag',
@@ -38,13 +34,15 @@ def is_git_dir(d):
but at least clearly indicates that we don't support it.
There is the unlikely danger to throw if we see directories which just look like a worktree dir,
but are none."""
- if isdir(d):
- if isdir(join(d, 'objects')) and isdir(join(d, 'refs')):
- headref = join(d, 'HEAD')
- return isfile(headref) or \
- (os.path.islink(headref) and
+ if osp.isdir(d):
+ if osp.isdir(osp.join(d, 'objects')) and osp.isdir(osp.join(d, 'refs')):
+ headref = osp.join(d, 'HEAD')
+ return osp.isfile(headref) or \
+ (osp.islink(headref) and
os.readlink(headref).startswith('refs'))
- elif isfile(join(d, 'gitdir')) and isfile(join(d, 'commondir')) and isfile(join(d, 'gitfile')):
+ elif (osp.isfile(osp.join(d, 'gitdir')) and
+ osp.isfile(osp.join(d, 'commondir')) and
+ osp.isfile(osp.join(d, 'gitfile'))):
raise WorkTreeRepositoryUnsupported(d)
return False
@@ -62,8 +60,11 @@ def find_git_dir(d):
else:
if content.startswith('gitdir: '):
path = content[8:]
- if not os.path.isabs(path):
- path = join(dirname(d), path)
+ if Git.is_cygwin():
+ ## Cygwin creates submodules prefixed with `/cygdrive/...` suffixes.
+ path = decygpath(path)
+ if not osp.isabs(path):
+ path = osp.join(osp.dirname(d), path)
return find_git_dir(path)
# end handle exception
return None