summaryrefslogtreecommitdiff
path: root/git/repo/fun.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2014-11-19 11:10:39 +0100
committerSebastian Thiel <byronimo@gmail.com>2014-11-19 11:10:39 +0100
commit22c4671b58a6289667f7ec132bc5251672411150 (patch)
tree323e062bd2f7abc294ac3cd047fe51dea0dc7245 /git/repo/fun.py
parent6fc9e6150957ff5e011142ec5e9f8522168602ec (diff)
parent53b65e074e4d62ea5d0251b37c35fd055e403110 (diff)
downloadgitpython-22c4671b58a6289667f7ec132bc5251672411150.tar.gz
Merge branch 'separate-git-dir' of https://github.com/niyaton/GitPython into niyaton-separate-git-dir
Conflicts: git/repo/base.py
Diffstat (limited to 'git/repo/fun.py')
-rw-r--r--git/repo/fun.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/git/repo/fun.py b/git/repo/fun.py
index 9dfc00ea..f5abc27a 100644
--- a/git/repo/fun.py
+++ b/git/repo/fun.py
@@ -45,6 +45,17 @@ def find_git_dir(d):
return find_git_dir(d)
return None
+def read_gitfile(f):
+ """ This is taken from the git setup.c:read_gitfile function.
+ :return gitdir path or None if gitfile is invalid."""
+
+ if not isfile(f):
+ return None
+ line = open(f, 'r').readline().rstrip()
+ if line[0:8] != 'gitdir: ':
+ return None
+ path = os.path.realpath(line[8:])
+ return path if is_git_dir(path) else None
def short_to_long(odb, hexsha):
""":return: long hexadecimal sha1 from the given less-than-40 byte hexsha