summaryrefslogtreecommitdiff
path: root/git/repo/fun.py
diff options
context:
space:
mode:
authorRemi Rampin <remirampin@gmail.com>2014-04-24 14:03:25 -0400
committerRemi Rampin <remirampin@gmail.com>2014-04-24 14:03:25 -0400
commitec0b85e2d4907fb5fcfc5724e0e8df59e752c0d1 (patch)
tree87a6fe7b21d40b3544a9815e537a6b8997694ca0 /git/repo/fun.py
parente6a2942a982c2541a6b6f7c67aa7dbf57ed060ca (diff)
downloadgitpython-ec0b85e2d4907fb5fcfc5724e0e8df59e752c0d1.tar.gz
Fixes creating a Repo for a submodule
Fixes #155.
Diffstat (limited to 'git/repo/fun.py')
-rw-r--r--git/repo/fun.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/git/repo/fun.py b/git/repo/fun.py
index 7a8657ab..2c49d836 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -7,6 +7,7 @@ from gitdb.util import (
join,
isdir,
isfile,
+ dirname,
hex_to_bin,
bin_to_hex
)
@@ -31,6 +32,18 @@ def is_git_dir(d):
return False
+def find_git_dir(d):
+ if is_git_dir(d):
+ return d
+ elif isfile(d):
+ with open(d) as fp:
+ content = fp.read().rstrip()
+ if content.startswith('gitdir: '):
+ d = join(dirname(d), content[8:])
+ return find_git_dir(d)
+ return None
+
+
def short_to_long(odb, hexsha):
""":return: long hexadecimal sha1 from the given less-than-40 byte hexsha
or None if no candidate could be found.